Go Down

Topic: (SOLVED)Error of multiple defination(by using a library in another library) (Read 419 times) previous topic - next topic

Cybernetician

Nov 23, 2012, 07:10 am Last Edit: Nov 23, 2012, 02:17 pm by Cybernetician Reason: 1
After reading this thread http://arduino.cc/forum/index.php/topic,120624.0.html i try this but Error of multiple defination start occuring what is the reason behind it?
I really appreciate your suggestions.

Sketch
Code: [Select]

#include "WebPages.h"
#include <SPI.h>
#include <Ethernet.h>
#include "WebServer.h"

WebPages Pages;

void setup()
{
 Pages.setup();
}

void loop()
{
 Pages.servProcess();
}



WebPages.h
Code: [Select]

#ifndef WebPages_h
#define WebPages_h

#include "WebServer.h"
#include "Arduino.h"
#include <SPI.h>
#include <Ethernet.h>


class WebPages
{
 public:
   WebPages();
void setup();
void servProcess();
private:
static void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete);
};

//extern WebPages Pages;
#endif



WebPages.cpp
Code: [Select]

#include "WebPages.h"

#include <SPI.h>
#include <Ethernet.h>
#include "Arduino.h"

template<class T>
inline Print &operator <<(Print &obj, T arg)
{ obj.print(arg); return obj; }


static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static uint8_t ip[] = { 192, 168, 1, 210 };
#define PREFIX ""
WebServer webserver(PREFIX, 80);

WebPages::WebPages()
{
//created
}
void WebPages::defaultCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
 P(htmlHead) =
   "<html>"
   "<head>"
   "<title>Arduino Web Server</title>"
   "<style type=\"text/css\">"
   "BODY { font-family: sans-serif }"
   "H1 { font-size: 14pt; text-decoration: underline }"
   "P  { font-size: 10pt; }"
   "</style>"
   "</head>"
   "<body>"
"TEST"
"</body>";
 server.httpSuccess();
 server.printP(htmlHead);
}
void WebPages::setup()
{
Ethernet.begin(mac, ip);
webserver.begin();
webserver.setDefaultCommand(&WebPages::defaultCmd);
}

void WebPages::servProcess()
{
webserver.processConnection();
}

//WebPages Pages = WebPages();



WebServer.h file of webduino


ERRORS
Quote

WebPages\WebPages.cpp.o: In function `WebServer::setDefaultCommand(void (*)(WebServer&, WebServer::ConnectionType, char*, bool))':
/WebServer.h:356: multiple definition of `WebServer::setDefaultCommand(void (*)(WebServer&, WebServer::ConnectionType, char*, bool))'
Webpages.cpp.o:D:\arduino-1\libraries\WebPages/WebServer.h:356: first defined here
WebPages\WebPages.cpp.o: In function `WebServer::setFailureCommand(void (*)(WebServer&, WebServer::ConnectionType, char*, bool))':
/WebServer.h:361: multiple definition of `WebServer::setFailureCommand(void (*)(WebServer&, WebServer::ConnectionType, char*, bool))'
Webpages.cpp.o:D:\arduino-1\libraries\WebPages/WebServer.h:361: first defined here
WebPages\WebPages.cpp.o: In function `WebServer::addCommand(char const*, void (*)(WebServer&, WebServer::ConnectionType, char*, bool))':
/WebServer.h:364: multiple definition of `WebServer::addCommand(char const*, void (*)(WebServer&, WebServer::ConnectionType, char*, bool))'
Webpages.cpp.o:D:\arduino-1\libraries\WebPages/WebServer.h:364: first defined here
WebPages\WebPages.cpp.o: In function `WebServer::push(int)':


Other in txt attach file
From Idea To Invention

guix

Edit: Sorry I've misread, not sure what your problem might be :/

Try removing #include "WebServer.h" from your sketch.

Cybernetician

#2
Nov 23, 2012, 07:34 am Last Edit: Nov 23, 2012, 07:44 am by Cybernetician Reason: 1
Quote

Hello, in your sketch, remove all includes but this one:
Code:
Code: [Select]
#include "WebServer.h"
Should work...or not


Did not work because library header file "WebPages.h"


Quote

Edit: Sorry I've misread, not sure what your problem might be :/

Try removing #include "WebServer.h" from your sketch.


EDIT: By doing this Same Errors there Sorry last time i mention wrong error
From Idea To Invention

Go Up