Pages: [1]   Go Down
Author Topic: (SOLVED)Error of multiple defination(by using a library in another library)  (Read 383 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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:
#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

* error.txt (11.12 KB - downloaded 6 times.)
« Last Edit: November 23, 2012, 08:17:28 am by Cybernetician » Logged

From Idea To Invention

France
Offline Offline
Edison Member
*
Karma: 37
Posts: 1004
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Try removing #include "WebServer.h" from your sketch.
« Last Edit: November 23, 2012, 01:31:52 am by guix » Logged

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Hello, in your sketch, remove all includes but this one:
Code:
Code:
#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
« Last Edit: November 23, 2012, 01:44:13 am by Cybernetician » Logged

From Idea To Invention

Pages: [1]   Go Up
Jump to: