dimanche 19 juillet 2020

C++11 -bash: ./program: No such device

Currently using Cygwin terminal and a C++ POSIX API to create a program. I keep getting these errors when not adding API files to compilation.

/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x39): undefined reference to `EReaderOSSignal::EReaderOSSignal(unsigned long)'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EReaderOSSignal::EReaderOSSignal(unsigned long)'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x60): undefined reference to `EClientSocket::EClientSocket(EWrapper*, EReaderSignal*)'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EClientSocket::EClientSocket(EWrapper*, EReaderSignal*)'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0xa1): undefined reference to `EReaderOSSignal::~EReaderOSSignal()'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0xa1): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EReaderOSSignal::~EReaderOSSignal()'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x108): undefined reference to `EReader::~EReader()'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x108): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EReader::~EReader()'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x14c): undefined reference to `EReaderOSSignal::~EReaderOSSignal()'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EReaderOSSignal::~EReaderOSSignal()'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x1ed): undefined reference to `EClientSocket::eConnect(char const*, int, int, bool)'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x1ed): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EClientSocket::eConnect(char const*, int, int, bool)'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x349): undefined reference to `EReader::EReader(EClientSocket*, EReaderSignal*)'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x349): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EReader::EReader(EClientSocket*, EReaderSignal*)'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x361): undefined reference to `EReader::start()'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x361): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EReader::start()'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x3fc): undefined reference to `EClient::isConnected() const'
/tmp/ccmIDQUc.o:connect_Client.cpp:(.text+0x3fc): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `EClient::isConnected() const'
collect2: error: ld returned 1 exit status

I am using Windows10. My compilation commands look like this:

g++ -pthread -Wall -Wno-switch -Wpedantic -std=c++11 connect_Client.cpp main.cpp -o con

If I compile adding API files like this:

 g++ -pthread -Wall -Wno-switch -Wpedantic -std=c++11 client/*.cpp connect_Client.cpp main.cpp -o con

The client/*.cpp being the API files,

It does compile but with warnings for one cpp file:

client/EOrderDecoder.cpp: In member function ‘char* EOrderDecoder::decodeContract(const char*&, const char*)’:
client/EOrderDecoder.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
client/EOrderDecoder.cpp: In member function ‘char* EOrderDecoder::decodeAction(const char*&, const char*)’:
client/EOrderDecoder.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }

There are more warnings but address the same thing for other methods in the cpp.

When I try run the executable Cygwin gives me an error:

./con
-bash: ./con: No such device

If I click on the executable it doesn't do anything. When I troubleshoot compatibility it says the specified path does not contain a valid program.
What error am I making?

Aucun commentaire:

Enregistrer un commentaire