Search code examples
eclipsemakefilearduinoavravr-gcc

avr-g++ compilation failed with Make Error 1


I'm trying to compile Arduino code in Eclipse. Below is the build log.

make all 
Building file: ../test.cpp
Starting C++ compile
"/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=163 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR     -I"/opt/arduino-1.6.3/hardware/arduino/avr/cores/arduino" -I"/opt/arduino-1.6.3/hardware/arduino/avr/variants/standard" -I/usr/lib/avr/include -MMD -MP -MF"test.cpp.d" -MT"test.cpp.d" -D__IN_ECLIPSE__=1 -x c++ "../test.cpp"  -o  "test.cpp.o"
as: unrecognized option '-mmcu=avr5'
make: *** [test.cpp.o] Error 1

What's wrong? What does as: unrecognized option '-mmcu=avr5' mean? It can't recognize the -mmcu option?


Solution

  • The error message is coming from the assembler as. The AVR assembler avr-as does accept the -mmcu option. Perhaps Eclipse is choosing some other as instead?

    Using "/bin/avr-g++" in the makefile looks suspicious to me. I would think that you should set up Eclipse to look for the toolchain in the right place without having to specify the directory in the makefile command.