Author Topic: Arduino and EtherCard.h  (Read 5062 times)

botezelli

  • Guest
Arduino and EtherCard.h
« on: October 08, 2014, 04:04:03 pm »
Hello everyone,

I'm trying to use <EtherCard.h> in Code::Blocks (Version 13.12 - Windows) but the compiler returns the error message below:

Test.ino: (.Text.setup + 0x2E) undefined reference to `EtherCard::begin(unsigned int, unsigned char const *, unsigned char)'

I've tried everything, but I can not compile successfully.

The same code works fine with the original Arduino IDE and also with Visual Micro (Arduino for Visual Studio).

But I want to use CodeBlocks which I love!

Does anyone know how to fix or give me an example of setting the correct environment CodeBlocks?


My simple code brief:

#include <Arduino.h>
#include <EtherCard.h>

#define BUF_SIZE 512

byte     mymac[]    = { 0x00, 0x04, 0xA3, 0x21, 0xCA, 0x38 };  // MAC address.
uint8_t myip[]       = { 192, 168, 0, 171 };                               // The IP address.
uint8_t dns[]         = { 8, 8, 8, 8 };                                          // The DNS server address.
uint8_t gateway[]  = { 192, 168, 0, 1 };                                   // The gateway router address.
uint8_t subnet[]    = { 255, 255, 255, 0 };                               // The subnet mask.

byte Ethernet::buffer[BUF_SIZE];

void setup()
{
...
   if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)  // Pin 10 = CS
...
}
...


Thank you so much,
Botezelli
« Last Edit: October 08, 2014, 04:08:36 pm by botezelli »

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Arduino and EtherCard.h
« Reply #1 on: October 08, 2014, 04:17:29 pm »
Did you setup the correct compiler for Arduino in project options? Do you have that compiler installed? Does it compile the code when run from command line? What are you specs (OS, CB version)?

Please remember this is not a general programming board, only CB related questions (setup problems, bug reports etc...) are allowed here as it is stated in the forum rules.

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: Arduino and EtherCard.h
« Reply #2 on: October 08, 2014, 04:34:18 pm »
Hello,
I use 'Code::Block 13.12' under 'VISTA' to compile 'Grbl' on Arduino.
Here is an address that will give you an example.
https://github.com/LETARTARE/Mega2560-grbl-0.8xx/tree/devGrbl
Best regards
CB-13515, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.6
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7608
    • My Best Post
Re: Arduino and EtherCard.h
« Reply #3 on: October 08, 2014, 04:36:34 pm »
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Post your build log here or on a site that supports your Compiler and you might get some help.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org