So I'm trying to to create a simple little program that will interface with an si570 I2C-controlled variable oscillator. The code that I started with as a library was originally for an mbed platform [1]. Opting to keep the class structure from the mbed library, I proceeded to use the included msp430-g++ compiler shipped with Energia.
I knocked up a quick Makefile based upon this thread here [2]:
OBJECTS = main.o SI570.o
CC = msp430-g++
CPPFLAGS =-Os -Wall -g -mmcu=msp430g2553
all : $(OBJECTS)
$(CC) $(CPPFLAGS) $(OBJECTS) -o main.elf
%.o : %.cpp
$(CC) $(CPPFLAGS) -c $<
clean:
rm -fr $(OBJECTS) main.elf
flash:
mspdebug tilib -d USB --force-reset "prog main.elf"
size:
msp430-size main.elf
So when I exercise make, I get the error of the linker not finding -lstdc++
If I add -nodefaultlibs to my CFLAGS, I got a metric crap ton of math library functions not being
c:\pimmel\workspace\msp430i2c>make msp430-g++ -Os -Wall -g -mmcu=msp430g2553 -nodefaultlibs -lm -lc -lgcc -c main.cpp msp430-g++ -Os -Wall -g -mmcu=msp430g2553 -nodefaultlibs -lm -lc -lgcc -c SI570.cpp SI570.cpp: In member function 'void SI570::get_registers()': SI570.cpp:76:24: warning: suggest parentheses around comparison in operand of '& ' [-Wparentheses] SI570.cpp:53:7: warning: unused variable 'i' [-Wunused-variable] msp430-g++ -Os -Wall -g -mmcu=msp430g2553 -nodefaultlibs -lm -lc -lgcc main.o SI570.o -o main.elf SI570.o: In function `SI570::get_registers()': SI570.cpp:(.text+0x26e): undefined reference to `__floatsisf' SI570.cpp:(.text+0x278): undefined reference to `__mulsf3' SI570.cpp:(.text+0x27c): undefined reference to `__fixunssfsi' SI570.cpp:(.text+0x280): undefined reference to `__floatunsisf' SI570.cpp:(.text+0x296): undefined reference to `__floatsisf' SI570.cpp:(.text+0x2a0): undefined reference to `__mulsf3' SI570.cpp:(.text+0x2ac): undefined reference to `__addsf3' SI570.cpp:(.text+0x2b0): undefined reference to `__fixunssfsi' SI570.cpp:(.text+0x2c0): undefined reference to `__floatunsisf' SI570.cpp:(.text+0x2ca): undefined reference to `__mulsf3' SI570.cpp:(.text+0x2fc): undefined reference to `__floatsisf' SI570.cpp:(.text+0x308): undefined reference to `__addsf3' (etc...)
I've tried differing combinations of the combination of -lm -lc -lgcc per a couple of stackoverflow posts [3], but nothing really seemed to change. Does anyone have any pointers for me on how to link this feller?
As an aside, I dropped the following bat file into the bin directory and when launched, it automatically adds the path for the compiler and msp430-debug. I found it convenient:
gccvar.bat
@echo off rem This file is the script to set path for mspgcc tool chain. set TL_PATH=%~dp0 set PATH=%TL_PATH%;%PATH%;%TL_PATH%\..\mspdebug cmd /K cd %CD%
[1] - http://mbed.org/users/soldeerridder/code/SI570/
[2] - http://forum.43oh.com/topic/835-makefile-for-mspgcc/
[3] - http://stackoverflow.com/questions/6534191/undefined-reference-to-only-some-math-h-functions