Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: botezelli on October 08, 2014, 04:04:03 pm

Title: Arduino and EtherCard.h
Post by: botezelli 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
Title: Re: Arduino and EtherCard.h
Post by: scarphin 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.
Title: Re: Arduino and EtherCard.h
Post by: LETARTARE 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 (https://github.com/LETARTARE/Mega2560-grbl-0.8xx/tree/devGrbl)
Best regards
Title: Re: Arduino and EtherCard.h
Post by: stahta01 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 (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.