Eclipse下使用arduinoEthernet.h
我想使用 eclipse 进行 Arduino 开发,但遇到一些问题。
我使用Eclipse + Eclipse AVR插件+ WinAVR。我设法将 Arduino 核心库编译成静态库。
现在我想使用我的以太网屏蔽,但我找不到在 Eclipse 中使用以太网库的方法。
将文件夹从 arduino-022/libraries/Ethernet 和 arduino-022/libraries/SPI 复制到我的项目文件夹,然后对包含的内容进行了一些更改为了工作。结果是关于
DDRB
和PORTB
的一些错误。将文件夹“以太网”和“SPI”添加到项目的包含路径中。结果如下。
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 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 library.
Now I want to use my ethernet shield but I can't find a way to use the ethernet library with Eclipse.
Copied the folder from
arduino-022/libraries/Ethernet
andarduino-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 aboutDDRB
andPORTB
.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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我花了一整天的时间试图弄清楚这一点,事实证明它实际上并不那么困难。损失的时间有点是由于某些设置对于 make 文件“不可见”。另外,生成的 eclipse makefile 对于任何人来说都是相当神秘的,无需深入研究手册。如果您想查看手册。找到解决方案本身:
简短版本:
创建 Arduino Core 库的静态库项目并构建它。
为SPI、w5100和以太网制作单独的静态库项目
要构建项目必须建立一些连接。首先,我将包含目录设置为正确指向,接下来我将对此进行描述。其次,我正确设置了项目引用,以便可以使用所有正确的依赖构建来构建应用程序。
请小心项目重命名,因为它们不会通过库设置和路径传播。还要注意设置中的一些理智,以便更容易捕获任何丢失和损坏的细节。
我将尝试稍后编辑更详细的解释,但这应该回答您的问题
编辑
我尝试仅导入以太网文件夹并从 if 中创建一个静态项目。由于一些奇怪的原因(我不知道 Eclipse 的详细信息),Eclipse 没有深入到实用程序文件夹中,有效地不编译它。如果它没有编译,并且由于您没有包含文件的静态库,您将在尝试编译以太网时获得未定义的引用。另外,静态库无法通过 avr eclipse 插件链接,但这实际上应该足够了。没有这样的对话框。
另外,在一个我无法解释并且几乎让我发疯的奇怪错误中,make 文件中的一些魔法通过 Eclipse 未定义的 cc 变量调用了编译器。问题已解决,将变量作为参数传递给 make.exe CC=avr-g++。
我更加努力地让它只在一个项目中工作,但它最终给了我在静态库构建中对 arduino core 的未定义引用,这让我完全惊呆了。
我知道这不是您问题的答案的一部分,但它应该留在这里,供任何人在使 Eclipse 成为事实上的 Arduino IDE 的过程中找到指导,这就是您所要求的。
我不明白你是如何得到有关 PORTB 和 DDRB 的错误的,但我认为这可能是构建中缺少的东西。就像我的例子一样,它只是发出无意义的错误报告。
课程是:将单独的库制作成静态库项目和引用,并将它们包含在最终应用程序的源代码和静态库中。
(旁注:Arduino IDE 应该被完全禁止并迁移到 Eclipse 或一些真正的 IDE)
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.
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)