2

我想使用 Eclipse 进行 Arduino 开发,但我遇到了一些问题。

我使用 Eclipse + Eclipse AVR 插件 + WinAVR。我设法将 Arduino 核心库编译成静态库。

现在我想使用我的以太网屏蔽,但我找不到在 Eclipse 中使用以太网库的方法。

  1. arduino-022/libraries/Ethernet将文件夹从我的项目文件夹复制arduino-022/libraries/SPI到我的项目文件夹,然后我对包含的内容进行了一些更改以工作。结果是关于DDRB和的一些错误PORTB

  2. 将文件夹 Ethernet 和 SPI 添加到项目的包含路径中。结果如下。

    
    main.cpp:(.text+0x8): undefined reference to `Server::Server(unsigned int)'
    ./main.o:在函数“循环”中:
    main.cpp:(.text+0x36): 未定义对“Server::available()”的引用
    main.cpp:(.text+0x3c): 未定义的对 `Client::operator bool()' 的引用
    main.cpp:(.text+0x56): 未定义对 `Client::available()' 的引用
    main.cpp:(.text+0x64): 未定义对 `Client::read()' 的引用
    main.cpp:(.text+0xf6): 未定义对 `Client::connected()' 的引用
    main.cpp:(.text+0x110): 未定义对 `Client::stop()' 的引用
    ./main.o:在函数“设置”中:
    main.cpp:(.text+0x138): 未定义对“以太网”的引用
    main.cpp:(.text+0x13a): 未定义对“以太网”的引用
    main.cpp:(.text+0x144): undefined reference to `EthernetClass::begin(unsigned char*, unsigned char*)'
    main.cpp:(.text+0x14c): 未定义对“Server::begin()”的引用

我不知道还能做什么。有没有人尝试过这样的事情?

4

1 回答 1

1

我花了一整天的时间试图弄清楚这一点,事实证明它实际上并没有那么困难。损失的时间是由于某些设置对 make 文件“不可见”。此外,如果没有深入研究手册,生成的 eclipse makefile 对任何人来说都是非常神秘的。如果您想查看手册。对于解决方案本身:

短版:制作 Arduino Core 库的静态库项目并构建它。

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)

于 2011-09-24T18:35:41.903 回答