Makefile doesn't work, but with ide works

Hi everybody,

I'm playing with arduino, leds and pushbuttons, and everything works cool, except by two things.

I use a Makefile to compile my sketches, but sometimes a get the following error:

applet/rainbow.cpp:103: undefined reference to `Print::println(char const*)'
applet/rainbow.cpp:106: undefined reference to `Print::println(char const*)'
applet/rainbow.cpp:109: undefined reference to `Print::println(char const*)'

I understand that means I need to include the Print.h, include it give me the same error, but if took the code and open it inside arduino ide compiles without errors, does somebody knows what could be wrong?

This is my sketch: This is my Makefile:

The second problem that I have (but I can live with this one) is that after execute 'make upload' to upload the program to arduino, I cannot repeat the operation without removing the usb cable from my laptop and the plugging it again, it gives me the following error:

make upload
/usr/bin/avrdude -V -F -C /etc/avrdude.conf -p atmega168 -P /dev/ttyUSB0 -c stk500v1 -b 19200 -U flash:w:applet/pushbutton.hex
avrdude: stk500_getsync(): not in sync: resp=0x06
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x06

avrdude done.  Thank you.

make: *** [upload] Error 1

I hope somebody could give a clue about what's wrong

BTW, I'm using debian unstable (sid)

Hi Felipe,

the #include of Print.h happens allready, no matter if you use makefile or the IDE.
But the new Print library itself (i.e. Print.cpp) must be known to the makfile. So you have to add “$(ARDUINO)/Print.cpp” to the CXXSRC variable in the makefile.

I just quickly compared the number of files in the core folders of 0011 and 0012. Print.cpp happens to be the only libary file which has been forgotten to get included in the makefile to be fully compatible with the Arduino IDE 0012.

for your upload problem with makefiles: try hitting the reset button manually just before you do “make upload”.


Instead of running make upload try:

  perl -MDevice::SerialPort -e 'Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(1000)'; avrdude -V -F -C /e
tc/avrdude.conf -v -v -p atmega328p -P /dev/ttyUSB0 -c stk500v1 -b 57600  -U flash:w:applet/sensorTestF_ver1.hex

you will need to get the perl modules and edit the avr command line but it does a pretty good job of sending a reset before the upload takes place