在Eclipse下使用arduino Ethernet.h

在Eclipse下使用arduino Ethernet.h,eclipse,arduino,ethernet,winavr,Eclipse,Arduino,Ethernet,Winavr,我想使用eclipse进行Arduino开发,我有一些问题 我使用Eclipse+eclipseavr插件+WinAVR。我设法将Arduino核心库编译成一个静态库 现在我想使用我的以太网屏蔽,但我找不到一种方法在Eclipse中使用以太网库 将文件夹从arduino-022/libraries/Ethernet和arduino-022/libraries/SPI复制到我的项目文件夹中,然后我对include进行了一些更改,以便工作。结果是关于DDRB和PORTB的一些错误 将Ethernet

我想使用eclipse进行Arduino开发,我有一些问题

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

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

  • 将文件夹从
    arduino-022/libraries/Ethernet
    arduino-022/libraries/SPI
    复制到我的项目文件夹中,然后我对include进行了一些更改,以便工作。结果是关于
    DDRB
    PORTB
    的一些错误

  • 将Ethernet和SPI文件夹添加到项目的include路径中。结果如下

  • main.cpp:(.text+0x8):对“Server::Server(unsigned int)”的未定义引用 ./main.o:在函数“loop”中: 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:在函数“setup”中: main.cpp:(.text+0x138):对“Ethernet”的未定义引用 main.cpp:(.text+0x13a):对“以太网”的未定义引用 main.cpp:(.text+0x144):对“EthernetClass::begin(unsigned char*,unsigned char*)”的未定义引用 main.cpp:(.text+0x14c):对“Server::begin()”的未定义引用
    我不知道还能做什么。有人试过这样的东西吗?

    我花了一整天的时间试图弄明白这一点,结果证明其实没那么难。损失的时间是由于某些设置对make文件是“不可见”的。此外,生成的eclipse makefiles对于任何人来说都非常神秘,不必深入阅读手册。如果您想查看解决方案本身的。步骤:

    简短版本: 制定Arduino核心库的静态库项目并进行构建

    为SPI、w5100和以太网制作单独的静态库项目 项目建设必须建立一些联系。首先,我将include目录设置为正确指向,下面将对其进行描述。其次,我将项目引用设置为正确的,这样就可以使用所有正确的依赖构建来构建应用程序

    • SPI->包括arduino内核
    • w5100->包括arduino堆芯和SPI
    • 以太网->包括arduino核心SPI和w5100
    • 应用程序本身->只包括w5100和以太网(假设它只是以太网库)
    • 应用程序本身->将项目的所有路径添加到库路径和相应的库(不带lib前缀)
    小心使用项目重命名,因为它们不会通过库设置和路径传播。还要注意你的设置是否合理,以便更容易捕捉到任何缺失和破坏的细节

    稍后我将尝试编辑更详细的解释,但这应该可以回答您的问题

    编辑

    我试着导入Ethernet文件夹,并用if创建一个静态项目。出于某种奇怪的原因(我不知道Eclipse的详细信息),Eclipse没有深入实用工具文件夹,也没有有效地编译它。如果它不编译,并且由于您没有包含文件的静态库,您将在编译Ethernet时得到未定义的引用。静态库也不能通过avr eclipse插件链接,这实际上已经足够了。没有这样的对话

    还有一个奇怪的错误,我无法解释,这让我几乎发疯,make文件中的一些魔法通过Eclipse没有定义的cc变量调用编译器。通过将变量作为参数传递给make like make.exe CC=avr-g++,问题得以解决。 我努力让它只在一个项目中工作,结果在静态库构建中给了我对arduino核心的未定义引用,这让我完全僵化了。 我知道这并不是你问题答案的一部分,但任何人都可以在这里找到指导,让Eclipse成为事实上的Arduino IDE,这就是你要问的

    我不明白您是如何得到关于PORTB和DDRB的错误的,但我认为这可能是构建中缺少的东西。在我的例子中,它只是发出无意义的错误报告

    教训是:将单独的库制作成静态库项目和引用,并将它们包含在最终应用程序的源代码和静态库中


    (旁注:Arduino IDE应该被完全禁止,并迁移到Eclipse或一些真正的IDE)

    感谢您的支持。我会检查一下,看看会发生什么。我也有同样的问题,这对我的项目至关重要。希望它能起作用 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()'