since I am searching now days for a solution I take the risk and ask you for help.
I am having an issue with implementing Serial.h in my project. The Serial.h file can be found here
https://github.com/yan9a/serial/blob/master/Serial.h
I included the header file in my SCdeckmain.h file as I have to declare 'Serial com;' as follows
Code: Select all
#include "Serial.h"
...
class SCdeckFrame: public wxFrame
{
public:
Serial com; // Inherit from Serial.h
SCdeckFrame(wxWindow* parent,wxWindowID id = -1);
virtual ~SCdeckFrame();
private:
//(*Handlers(SCdeckFrame)
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnConnect(wxCommandEvent& event);
...
Code: Select all
obj\Debug\SCdeckMain.o||In function `ZSt19__iterator_categoryIN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEENSt15iterator_traitsIT_E17iterator_categoryERKSB_':|
D:\Documents\Coding\SCdeck\Serial.h|96|multiple definition of `Serial::Serial()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|96|first defined here|
obj\Debug\SCdeckMain.o||In function `ZSt19__iterator_categoryIN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEENSt15iterator_traitsIT_E17iterator_categoryERKSB_':|
D:\Documents\Coding\SCdeck\Serial.h|96|multiple definition of `Serial::Serial()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|96|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN14wxFormatStringC1EPKw':|
D:\Documents\Coding\SCdeck\Serial.h|111|multiple definition of `Serial::Serial(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long, long, char, float)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|111|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN14wxFormatStringC1EPKw':|
D:\Documents\Coding\SCdeck\Serial.h|111|multiple definition of `Serial::Serial(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long, long, char, float)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|111|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6SerialD2Ev':|
D:\Documents\Coding\SCdeck\Serial.h|125|multiple definition of `Serial::~Serial()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|125|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6SerialD2Ev':|
D:\Documents\Coding\SCdeck\Serial.h|125|multiple definition of `Serial::~Serial()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|125|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial7SetPortENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE':|
D:\Documents\Coding\SCdeck\Serial.h|130|multiple definition of `Serial::SetPort(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|130|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial7GetPortB5cxx11Ev':|
D:\Documents\Coding\SCdeck\Serial.h|134|multiple definition of `Serial::GetPort[abi:cxx11]()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|134|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial11SetDataSizeEl':|
D:\Documents\Coding\SCdeck\Serial.h|138|multiple definition of `Serial::SetDataSize(long)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|138|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial11GetDataSizeEv':|
D:\Documents\Coding\SCdeck\Serial.h|143|multiple definition of `Serial::GetDataSize()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|143|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial9SetParityEc':|
D:\Documents\Coding\SCdeck\Serial.h|147|multiple definition of `Serial::SetParity(char)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|147|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial9GetParityEv':|
D:\Documents\Coding\SCdeck\Serial.h|158|multiple definition of `Serial::GetParity()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|158|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial11SetStopBitsEf':|
D:\Documents\Coding\SCdeck\Serial.h|162|multiple definition of `Serial::SetStopBits(float)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|162|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial11GetStopBitsEv':|
D:\Documents\Coding\SCdeck\Serial.h|170|multiple definition of `Serial::GetStopBits()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|170|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial11SetBaudRateEl':|
D:\Documents\Coding\SCdeck\Serial.h|178|multiple definition of `Serial::SetBaudRate(long)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|178|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial11GetBaudRateEv':|
D:\Documents\Coding\SCdeck\Serial.h|195|multiple definition of `Serial::GetBaudRate()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|195|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial4OpenEv':|
D:\Documents\Coding\SCdeck\Serial.h|200|multiple definition of `Serial::Open()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|200|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial5CloseEv':|
D:\Documents\Coding\SCdeck\Serial.h|274|multiple definition of `Serial::Close()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|274|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial8IsOpenedEv':|
D:\Documents\Coding\SCdeck\Serial.h|286|multiple definition of `Serial::IsOpened()'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|286|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial5WriteEPc':|
D:\Documents\Coding\SCdeck\Serial.h|294|multiple definition of `Serial::Write(char*)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|294|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial9WriteCharEc':|
D:\Documents\Coding\SCdeck\Serial.h|317|multiple definition of `Serial::WriteChar(char)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|317|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial8ReadCharERb':|
D:\Documents\Coding\SCdeck\Serial.h|325|multiple definition of `Serial::ReadChar(bool&)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|325|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial6SetRTSEb':|
D:\Documents\Coding\SCdeck\Serial.h|371|multiple definition of `Serial::SetRTS(bool)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|371|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial6SetDTREb':|
D:\Documents\Coding\SCdeck\Serial.h|385|multiple definition of `Serial::SetDTR(bool)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|385|first defined here|
obj\Debug\SCdeckMain.o||In function `ZN6Serial6GetCTSERb':|
D:\Documents\Coding\SCdeck\Serial.h|399|multiple definition of `Serial::GetCTS(bool&)'|
obj\Debug\SCdeckApp.o:D:\Documents\Coding\SCdeck\Serial.h|399|first defined here|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 35 warning(s) (0 minute(s), 2 second(s)) ===|
I can compile the example wxwidgets file without any issues.
I neither have included Serial.h twice nor declared the definitons a second time anywhere. So I don't understand why the linker has the opinion that there are multiple definitions.
Small repro (codeblocks) is attached