Problem With Eclipse IDE / Arduino

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
nateloaf
 
Posts: 41
Joined: Fri Mar 05, 2010 3:31 pm

Problem With Eclipse IDE / Arduino

Post by nateloaf »

I stumbled onto a few blog posts elsewhere that outline how to set up the Eclipse IDE for use with Arduino. I was overjoyed, as the Arduino IDE is too klunky and Eclipse is excellent.

I used the instructions from: http://www.chipkin.com/articles/using-e ... uemilanove which seem to be straightforward, however I am getting the following error when building a sample application:

Code: Select all

Building target: Blinky.elf
Invoking: AVR C++ Linker
avr-gcc --cref -s -Os -o"Blinky.elf"  ./main.o   -lArduinoCore -lm -Wl,-Map,Blinky.map,--cref -L"/home/nwild/workspace/ArduinoCore/Release" -mmcu=atmega328p
/usr/lib/gcc/avr/4.3.4/../../../avr/lib/avr5/crtm328p.o: In function `__bad_interrupt':
../../../../crt1/gcrt1.S:193: undefined reference to `main'
make: *** [Blinky.elf] Error 1
I did the same procedure from a Windows PC and get a similar error:

Code: Select all

Building target: Blinky.elf
Invoking: AVR C++ Linker
avr-gcc –cref -s -Os -o”Blinky.elf” ./Main.o -lArduinoCore -lm -Wl,-Map,Blinky.map,–cref -L”X:\ArduinoCore\Release” -mmcu=atmega328p
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr5/crtm328p.o:(.init9+0×0): undefined reference to `main’
make: *** [Blinky.elf] Error 1
Obviously I am missing something, as the linker appears not to be including my main file (it is generation a main.o, so I'm guessing it is compiling it without errors though?!)

Any help would be appreciated...

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Problem With Eclipse IDE / Arduino

Post by westfw »

You need to include the main.o that is compiled from the Arduino "core" main.cpp (which I think gets put into the "core.o" library), PLUS the .o file from your own sketch (which ought to be called something like "blinky.o"

A lot of the eclipse instructions out there are pretty out-of-date; be sure to search the Arduino forums for recent discussions (fortunately, "eclipse" is a good search term.)

Applications/arduino/arduino-0021/Arduino-0021.app/Contents/Resources/Java/hardware/tools/avr/bin

The final link command (copied from the Arduino IDE) ends up looking like:
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/applet1234/Fading.cpp.elf /tmp/applet1234/Fading.cpp.o /tmp/applet1234/core.a -L/tmp/applet1234 -lm
The final command produced by eclipse ought to look similar.
(This is for the "fading" example sketch, with /tmp/applet1234 as the general build directory.)

nateloaf
 
Posts: 41
Joined: Fri Mar 05, 2010 3:31 pm

Re: Problem With Eclipse IDE / Arduino

Post by nateloaf »

Thanks for the reply. I suspected it would be you that chimed in - you are one helpful dude...

I excluded the Arduino Main.cpp when I built my libArduinoCore.a, but my project includes a main module includes the setup() and loop() functions as well as a main() that calls them and init() appropriately. It looks like my main.cpp is getting compiled, and the resulting main.o is included in the linker command line...

nateloaf
 
Posts: 41
Joined: Fri Mar 05, 2010 3:31 pm

Re: Problem With Eclipse IDE / Arduino

Post by nateloaf »

I'm replying to myself in case some future noob Googles this topic and has a similar problem. The issue turned out to be because the main module in my application (yay! now that I'm using Eclipse I can call it an application instead of a sketch - which always seemed dumb to me) was called "main.cpp" which seems to have confused the linker (two main.o's I guess). I wouldn't have thought that would have been an issue, but it apparently was - and not one that the error message pointed me in the direction of.

The second issue appears to be with the inclusion of the static libraries that I generated. Adding the release folders to my library path, and adding the libraries to my library list did not cause the linker to include them for some reason. I just added the libXXX.a files into the linker settings as "Other Objects" and it works like a charm.

I now have a real working IDE and couldn't be happier :)

User avatar
monkeybanjo
 
Posts: 1
Joined: Fri Aug 31, 2012 4:38 am

Re: Problem With Eclipse IDE / Arduino

Post by monkeybanjo »

Thanks Nateloaf! Just been having exactly the same problems as you, and solved them thanks to your post. You've turned my frown upside down :-)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”