DHCP library

Hi all,

15 years since i did any programming and this is my first post so go easy on me.
I have the ethernet shield and have tried the example sketches which work when i alter the hard coded ip addresses.

Next step see if i can get Jordan Terrel'ls DHCP library to grab an ip address, but the example that comes with it 'WebClientWithDHCP' just wont compile. I get:-

/Users/tom/Documents/Arduino/libraries/ArduinoDHCPv0/Dhcp.cpp:361: error: 'Sn_CR_RECV' was not declared in this scope

I went looking for the definition for 'Sn_CR_RECV' and its in w5100.h
looking in 'Dhcp.cpp' i see that 'w5100.h' is included right at the top as follows

// DHCP Library v0.3 - April 25, 2009
// Author: Jordan Terrell - blog.jordanterrell.com

extern "C" {
#include "types.h"
#include "w5100.h"
#include "sockutil.h"
#include "socket.h"
#include "spi.h"
}

probably something simple but i cant see what it is

Thanks in advance
Tom

Well, I don't have that particular library, or example sketch, so I'm just shooting in the dark, but...

There is a quirk of the Arduino IDE that determines what gets compiled and included. Only include files that are included in the sketch (or are included in files included in the sketch) seem to be available for inclusion by code being compiled.

Does the sketch include the w5100.h file? If not, does anything change if you include it?

Thanks paul for your input, i did think of that myself but no joy

bit more experimenting

this code compiles no surprise...

#include <Ethernet.h>

void setup ()
{}
void loop ()
{}

but this does not it gives the same error as the dhcp client example

#include <Ethernet.h>
#include "Dhcp.h"

void setup ()
{}
void loop ()
{}

Where did you get the DHCP library?

Jordan Terrel's website here

I am a mac user do you think that any difference to the way things compile?

Is that error the only one you get? I downloaded the library and compiled it using Arduino 0018, on Windows XP. I get a lot more errors than that one.

Which Ethernet library are you using?

[edit]I figured out my problem. I was supposed to add the DCHP library to the Ethernet library, not to a separate library. When I did that, it compiled with no errors. So, now I have to ask what board you have. I have a Duemilanove. I don't know if it makes any difference.[/edit]

woohoo! got it compiled and it works!!!

Paul,thanks so much for taking the time to try this for me.

I had sort of tried to install the library within the Ethernet folder but i had not been as thorough as i should have been. Your success meant that that was the correct approach.

For the record this is what i did to get it to compile for a Duemilanove on a Mac

Jordans library contains the main dhcp code and a utility subfolder with some basic networking code. Copy all code and header files to:-

/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet

copy the DHCP example to

/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/examples

I still have a lot to learn...

Though i have it working, is this the correct way to do it? Jordan must have created the utility folder for a reason, why do i have to move the files out of that folder

The Ethernet library also contains a utility folder. The DHCP/utility files should go in Ethernet/utility.

However, the Arduino IDE is relatively flexible in searching for include files, so it might not strictly be necessary.

It's why Jordan "created" a utility folder, though. I'm sure his library (DHCP.cpp and DHCP.h) was developed in the Ethernet directory structure, and then the DHCP specific files were extracted into their own zip file fir distribution.

Paul,

you are correct, I moved the util.c/.h and sockutil.c/.h to the ethernet utility folder and it works also

Thanks again

Hello everyone,

I just installed the DHCP library and when I compile I get a error message EthernetDCHP.h : No such file pr directory In function 'void setup()':In function 'void loop()': I looked in the library and the header and cpp files are there. Has anyone ran into this?

I just installed the DHCP library and when I compile I get a error message EthernetDCHP.h : No such file pr directory

This is telling you "Hey, I can't find this file". It (typically) means that you did not install the library in the right place.

Did you restart the IDE after installing the DHCP library? In the IDE, using Sketch + Import Library, can you import the DHCP library?

Re: DHCP library
Reply #11 - Today at 00:15:31 | Quote:

I just installed the DHCP library and when I compile I get a error message EthernetDCHP.h : No such file pr directory
This is telling you "Hey, I can't find this file". It (typically) means that you did not install the library in the right place.

Did you restart the IDE after installing the DHCP library? In the IDE, using Sketch + Import Library, can you import the DHCP library?

Yes I can import the libraries but I have error messages now out the wazoo Only when I import the EthernetDHCP library. Alot of the messages are multiple definitions. I have each one as its own library the EthernetDNS EthernetBonjour EthernetDHCP. Do I have to merge the DHCP with one of the other libraries?