Collect2.exe error returned 1 exit status

Mar 17, 2020 at 6:05am
Collect2.exe error returned 1 exit status


c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x4849): undefined reference
to `eobot::register_handler(PacketFamily, PacketAction, bool (*)(PacketReader))
'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x4865): undefined reference
to `eobot::register_handler(PacketFamily, PacketAction, bool (*)(PacketReader))
'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x4881): undefined reference
to `eobot::register_handler(PacketFamily, PacketAction, bool (*)(PacketReader))
'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x48bf): undefined reference
to `TimeEvent::TimeEvent(void (*)(void*), void*, double, int, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x48ca): undefined reference
to `eobot::timer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x48cf): undefined reference
to `Timer::Register(TimeEvent*)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x4910): undefined reference
to `TimeEvent::TimeEvent(void (*)(void*), void*, double, int, bool)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x491b): undefined reference
to `eobot::timer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x4920): undefined reference
to `Timer::Register(TimeEvent*)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text+0x4928): undefined reference
to `eobot::main()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountC1Ev[__ZN
6Shared8RefCountC1Ev]+0x13): undefined reference to `shared_objects_allocated_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountC1Ev[__ZN
6Shared8RefCountC1Ev]+0x1b): undefined reference to `shared_objects_allocated_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountC1Ev[__ZN
6Shared8RefCountC1Ev]+0x20): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountC1Ev[__ZN
6Shared8RefCountC1Ev]+0x28): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountmmEv[__ZN
6Shared8RefCountmmEv]+0x23): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountmmEv[__ZN
6Shared8RefCountmmEv]+0x2b): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountppEv[__ZN
6Shared8RefCountppEv]+0x23): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountppEv[__ZN
6Shared8RefCountppEv]+0x2b): more undefined references to `shared_references_' f
ollow
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountD1Ev[__ZN
6Shared8RefCountD1Ev]+0xa): undefined reference to `shared_objects_allocated_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountD1Ev[__ZN
6Shared8RefCountD1Ev]+0x12): undefined reference to `shared_objects_allocated_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountD1Ev[__ZN
6Shared8RefCountD1Ev]+0x18): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN6Shared8RefCountD1Ev[__ZN
6Shared8RefCountD1Ev]+0x26): undefined reference to `shared_references_'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN16GenericPtrVectorD2Ev[__
ZN16GenericPtrVectorD2Ev]+0xa): undefined reference to `vtable for GenericPtrVec
tor'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN3EIFC1ENSt7__cxx1112basic
_stringIcSt11char_traitsIcESaIcEEE[__ZN3EIFC1ENSt7__cxx1112basic_stringIcSt11cha
r_traitsIcESaIcEEE]+0x4a): undefined reference to `EIF::Read(std::__cxx11::basic
_string<char, std::char_traits<char>, std::allocator<char> >)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN3ENFC1ENSt7__cxx1112basic
_stringIcSt11char_traitsIcESaIcEEE[__ZN3ENFC1ENSt7__cxx1112basic_stringIcSt11cha
r_traitsIcESaIcEEE]+0x4a): undefined reference to `ENF::Read(std::__cxx11::basic
_string<char, std::char_traits<char>, std::allocator<char> >)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN3ESFC1ENSt7__cxx1112basic
_stringIcSt11char_traitsIcESaIcEEE[__ZN3ESFC1ENSt7__cxx1112basic_stringIcSt11cha
r_traitsIcESaIcEEE]+0x4a): undefined reference to `ESF::Read(std::__cxx11::basic
_string<char, std::char_traits<char>, std::allocator<char> >)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN3ECFC1ENSt7__cxx1112basic
_stringIcSt11char_traitsIcESaIcEEE[__ZN3ECFC1ENSt7__cxx1112basic_stringIcSt11cha
r_traitsIcESaIcEEE]+0x4a): undefined reference to `ECF::Read(std::__cxx11::basic
_string<char, std::char_traits<char>, std::allocator<char> >)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZN16GenericPtrVectorC2Ev[__
ZN16GenericPtrVectorC2Ev]+0x14): undefined reference to `vtable for GenericPtrVe
ctor'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.text$_ZNSt4pairIKNSt7__cxx1112bas
ic_stringIcSt11char_traitsIcESaIcEEEN4util7variantEEC1IJOS5_EJLj0EEJEJEEERSt5tup
leIJDpT_EERSC_IJDpT1_EESt12_Index_tupleIJXspT0_EEESL_IJXspT2_EEE[__ZNSt4pairIKNS
t7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN4util7variantEEC1IJOS5_EJLj0E
EJEJEEERSt5tupleIJDpT_EERSC_IJDpT1_EESt12_Index_tupleIJXspT0_EEESL_IJXspT2_EEE]+
0x36): undefined reference to `util::variant::variant()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.rdata$_ZTV9PtrVectorI8ECF_DataE[_
_ZTV9PtrVectorI8ECF_DataE]+0x1c): undefined reference to `GenericPtrVector::resi
ze(unsigned int)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.rdata$_ZTV9PtrVectorI8ESF_DataE[_
_ZTV9PtrVectorI8ESF_DataE]+0x1c): undefined reference to `GenericPtrVector::resi
ze(unsigned int)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.rdata$_ZTV9PtrVectorI8ENF_DataE[_
_ZTV9PtrVectorI8ENF_DataE]+0x1c): undefined reference to `GenericPtrVector::resi
ze(unsigned int)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\D
ekota\AppData\Local\Temp\cc5BFTX5.o:main.cpp:(.rdata$_ZTV9PtrVectorI8EIF_DataE[_
_ZTV9PtrVectorI8EIF_DataE]+0x1c): undefined reference to `GenericPtrVector::resi
ze(unsigned int)'
collect2.exe: error: ld returned 1 exit status




if anyone could help that would be greatly appreciated thank you
Mar 17, 2020 at 6:46am
It looks like you forgot to tell the linker about certain libraries your source code depends on.

You have a nice 3rd party library called 'FooBar'

In your source code, you say
#include <foobar.h>

To make it compile, you tell your compiler / IDE / Makefile some information on where to find the header file. From the command line, you would add -I/path/to/foobar/include which is the directory containing foobar.h

To make it link (ie, resolve all those undefined reference to errors), you also have to tell the linker the same kind of information. Say FooBar is compiled as a library called libfoobar.a which happens to be in /path/to/foobar/lib.
From the command line, you would add -L/path/to/foobar/lib -lfoobar to tell the linker the location and name of the library.

Topic archived. No new replies allowed.