开发者

Using arduino Ethernet.h under Eclipse

I want to use eclipse for Arduino development and I have some issues.

I use Eclipse + Eclipse AVR plugin + WinAVR. I managed to compile the Arduino core library into a static 开发者_如何学Golibrary.

Now I want to use my ethernet shield but I can't find a way to use the ethernet library with Eclipse.

  1. Copied the folder from arduino-022/libraries/Ethernet and arduino-022/libraries/SPI to my project folder and then I made some changes to the includes in order to work. The result is some errors about DDRB and PORTB.

  2. Added the folders Ethernet and SPI into the project's include path. The result is the following.

    
    main.cpp:(.text+0x8): undefined reference to `Server::Server(unsigned int)'
    ./main.o: In function `loop':
    main.cpp:(.text+0x36): undefined reference to `Server::available()'
    main.cpp:(.text+0x3c): undefined reference to `Client::operator bool()'
    main.cpp:(.text+0x56): undefined reference to `Client::available()'
    main.cpp:(.text+0x64): undefined reference to `Client::read()'
    main.cpp:(.text+0xf6): undefined reference to `Client::connected()'
    main.cpp:(.text+0x110): undefined reference to `Client::stop()'
    ./main.o: In function `setup':
    main.cpp:(.text+0x138): undefined reference to `Ethernet'
    main.cpp:(.text+0x13a): undefined reference to `Ethernet'
    main.cpp:(.text+0x144): undefined reference to `EthernetClass::begin(unsigned char*, unsigned char*)'
    main.cpp:(.text+0x14c): undefined reference to `Server::begin()'

I don't know what else to do. Has anyone tried something like this?


I have lost all day trying to figure this out and it turns out its actually not that difficult. The lost time is due a bit to the fact that some settings are "invisible" to the make file. Also the generated eclipse makefiles are quite cryptic for anybody without delving into the manual. If you want to take a look at the manual.To the solution itself:

Short version: Make a static library project of the Arduino Core library and build it.

Make separate static library project for SPI, w5100 and Ethernet There are some connections which must be made for the projects to build. First I set the include directories to point correctly, which i will describe next. Second i set the project references correct so its possible to build the application with all the right dependent builds.

  • SPI -> includes the arduino core
  • w5100 -> includes arduino core and SPI
  • Ethernet -> includes arduino core SPI and w5100
  • The Application itself -> include just w5100 and Ethernet (assuming its just the Ethernet - library)
  • The Application itself -> add the all paths of your projects to the library paths and the respective libraries(without the lib prefix)

Be careful with project renames as they don't propagate through the library settings and paths. Be mindful also of some sanity in your setup so as to make it easier to catch any detail that is missing and breaking.

I will try to edit later with a more detailed explanation but this should answer your question

EDIT

I have tried to just import the Ethernet folder and make a static project out of if. For some weird reason(i don't know the details of Eclipse) Eclipse doesn't go deeper into the utility folder effectively not compiling it. If it does not compile and, as you dont have a static library for that include files you will get undefined references trying to compile Ethernet. Also static libraries cannot be linked through the avr eclipse plugin, and that should actually be enough. There is no such dialog.

Also in a weird error, which i cannot explain and which drove me almost nuts, some magic in the make file invoked the compiler through the cc variable which Eclipse did not define. The problem was solved passing the variable as an argument to make like make.exe CC=avr-g++. I tried harder to make it work through only one project and it just ended up giving me undefined references to arduino core in the static library build which got me completely petrified. I know this is not part of the answer to your question but it shall stay here for anybody to find guidance in the process of making Eclipse a de facto Arduino IDE, which is what you ask.

I don't understand how you got the errors regarding PORTB and DDRB but i think it was probably something missing in the build. As in my case it just spat non sense error reports.

The lesson is: Make the separate libraries into static library projects and reference and include them in source and in static library in your final application.

(Side note: Arduino IDE should be completely banned and migrated to Eclipse or some real IDE)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜