我花了一整天的时间试图弄清楚这一点,事实证明它实际上并没有那么困难。损失的时间是由于某些设置对 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)