Skip to main content
added 76 characters in body
Source Link

Help me out here. I don't know what I'm missing. I have this code in my arduino IDE

#include "Foo2.h"
void setup() {
  // put your setup code here, to run once:

}
void loop() {
  // put your main code here, to run repeatedly:
}

And I have threefive files: Foo.h, Foo.cpp and, Foo2.h, Foo3.cpp and Foo.h

Foo.h

#ifndef Foo_H
#define Foo_H

class Foo
{
    public:
    Foo();

    public:
    bool Fooa();
    bool Foob();
};
#endif

Foo.cpp

#include "Foo.h"

Foo::Foo()
{
    
}

bool Foo::Foob()
{
    return true;
}

Foo2.h

#ifndef Foo2_H
#define Foo2_H
#define LIBRARY_VERSION 1.0.0
#include "Foo.h"
    
bool Foo::Fooa()
{
    return true;
}
#endif

And it is give me an error:Foo3.h

Arduino:1.8.13#ifndef (WindowsFoo3_H
#define StoreFoo3_H
#include 1.8.42"Foo2.0)h"

class (WindowsFoo3
{
 10), Tarjeta  public:"Arduino 
 Mega or Mega 2560, ATmega2560   Foo3(Mega);
 2560       Foo _foo;
};
#endif

Foo3.cpp

#include "Foo3.h"

Foo3::Foo3()"
{
}

And it is give me an error:

libraries\Foo\Foo3.cpp.o (symbol from plugin): In function `Foo::Fooa()':
 
(.text+0x0): multiple definition of `Foo::Fooa()'
 
sketch\kk2.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
 
collect2.exe: error: ld returned 1 exit status
 
exit status 1

what i'm doing wrong

regards,

Help me out here. I don't know what I'm missing. I have this code in my arduino IDE

#include "Foo2.h"
void setup() {
  // put your setup code here, to run once:

}
void loop() {
  // put your main code here, to run repeatedly:
}

And I have three files: Foo.h, Foo.cpp and Foo2.h

Foo.h

#ifndef Foo_H
#define Foo_H

class Foo
{
    public:
    Foo();

    public:
    bool Fooa();
    bool Foob();
};
#endif

Foo.cpp

#include "Foo.h"

Foo::Foo()
{
    
}

bool Foo::Foob()
{
    return true;
}

Foo2.h

#ifndef Foo2_H
#define Foo2_H
#define LIBRARY_VERSION 1.0.0
#include "Foo.h"
    
bool Foo::Fooa()
{
    return true;
}
#endif

And it is give me an error:

Arduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), Tarjeta:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

libraries\Foo\Foo3.cpp.o (symbol from plugin): In function `Foo::Fooa()':
 
(.text+0x0): multiple definition of `Foo::Fooa()'
 
sketch\kk2.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
 
collect2.exe: error: ld returned 1 exit status
 
exit status 1

what i'm doing wrong

regards,

Help me out here. I don't know what I'm missing. I have this code in my arduino IDE

#include "Foo2.h"
void setup() {
  // put your setup code here, to run once:

}
void loop() {
  // put your main code here, to run repeatedly:
}

And I have five files: Foo.h, Foo.cpp, Foo2.h, Foo3.cpp and Foo.h

Foo.h

#ifndef Foo_H
#define Foo_H

class Foo
{
    public:
    Foo();

    public:
    bool Fooa();
    bool Foob();
};
#endif

Foo.cpp

#include "Foo.h"

Foo::Foo()
{
    
}

bool Foo::Foob()
{
    return true;
}

Foo2.h

#ifndef Foo2_H
#define Foo2_H
#define LIBRARY_VERSION 1.0.0
#include "Foo.h"
    
bool Foo::Fooa()
{
    return true;
}
#endif

Foo3.h

#ifndef Foo3_H
#define Foo3_H
#include "Foo2.h"

class Foo3
{
    public: 
        Foo3();
        Foo _foo;
};
#endif

Foo3.cpp

#include "Foo3.h"

Foo3::Foo3()
{
}

And it is give me an error:

libraries\Foo\Foo3.cpp.o (symbol from plugin): In function `Foo::Fooa()':
(.text+0x0): multiple definition of `Foo::Fooa()'
sketch\kk2.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1

what i'm doing wrong

regards,

Source Link

Multiple definition class in arduino

Help me out here. I don't know what I'm missing. I have this code in my arduino IDE

#include "Foo2.h"
void setup() {
  // put your setup code here, to run once:

}
void loop() {
  // put your main code here, to run repeatedly:
}

And I have three files: Foo.h, Foo.cpp and Foo2.h

Foo.h

#ifndef Foo_H
#define Foo_H

class Foo
{
    public:
    Foo();

    public:
    bool Fooa();
    bool Foob();
};
#endif

Foo.cpp

#include "Foo.h"

Foo::Foo()
{
    
}

bool Foo::Foob()
{
    return true;
}

Foo2.h

#ifndef Foo2_H
#define Foo2_H
#define LIBRARY_VERSION 1.0.0
#include "Foo.h"
    
bool Foo::Fooa()
{
    return true;
}
#endif

And it is give me an error:

Arduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), Tarjeta:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

libraries\Foo\Foo3.cpp.o (symbol from plugin): In function `Foo::Fooa()':

(.text+0x0): multiple definition of `Foo::Fooa()'

sketch\kk2.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1

what i'm doing wrong

regards,