This is not a bug but I did not find a better place to ask - so I'll give it a shot:
I'm trying to build the pmp-library under Ubuntu 20 in the Windows subsystem for Linux (WSL). More than half way through the build, I get lots of undefined references like this one:
I also found that it might be related to the command used for compiling. Using gcc
the c standard lib has to linked explicitly, using g++
it is linked automatically. But did not find the information in the make files.
Any idea how to fix this error? I posted the entire output below...
[ 59%] Linking CXX executable ../../mconvert /usr/bin/ld: CMakeFiles/mconvert.dir/mconvert.cpp.o: in function
std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&) [clone .isra.19]':
mconvert.cpp:(.text+0x86): undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)' /usr/bin/ld: mconvert.cpp:(.text+0xbc): undefined reference to
std::__throw_logic_error(char const*)'
/usr/bin/ld: CMakeFiles/mconvert.dir/mconvert.cpp.o: in function usage_and_exit()': mconvert.cpp:(.text+0xca): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text+0xd8): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' /usr/bin/ld: mconvert.cpp:(.text+0xe6): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text+0xf0): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' /usr/bin/ld: mconvert.cpp:(.text+0xf7): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text+0x103): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /usr/bin/ld: CMakeFiles/mconvert.dir/mconvert.cpp.o: in function
main':
mconvert.cpp:(.text.startup+0xff): undefined reference to operator delete(void*)' /usr/bin/ld: mconvert.cpp:(.text.startup+0x116): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text.startup+0x120): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' /usr/bin/ld: mconvert.cpp:(.text.startup+0x127): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text.startup+0x12f): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /usr/bin/ld: mconvert.cpp:(.text.startup+0x13e): undefined reference to
std::basic_ostream<char, std::char_traits >& std::operator<< <std::char_traits >(std::basic_ostream<char, std::char_traits >&, char const*)'
/usr/bin/ld: mconvert.cpp:(.text.startup+0x19d): undefined reference to operator delete(void*)' /usr/bin/ld: mconvert.cpp:(.text.startup+0x1b0): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text.startup+0x1ba): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' /usr/bin/ld: mconvert.cpp:(.text.startup+0x1c1): undefined reference to
std::cerr'
/usr/bin/ld: mconvert.cpp:(.text.startup+0x1c9): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /usr/bin/ld: mconvert.cpp:(.text.startup+0x1ee): undefined reference to
operator delete(void*)'
/usr/bin/ld: CMakeFiles/mconvert.dir/mconvert.cpp.o: in function _GLOBAL__sub_I__Z14usage_and_exitv': mconvert.cpp:(.text.startup+0x21c): undefined reference to
std::ios_base::Init::Init()'
/usr/bin/ld: mconvert.cpp:(.text.startup+0x223): undefined reference to std::ios_base::Init::~Init()' /usr/bin/ld: CMakeFiles/mconvert.dir/mconvert.cpp.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to
__gxx_personality_v0'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::basic_ios<char, std::char_traits >::init(std::basic_streambuf<char, std::char_traits >)'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::ctype<char>::_M_widen_init() const' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
VTT for std::__cxx11::basic_ostringstream<char, std::char_traits, std::allocator >'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::_Rb_tree_decrement(std::_Rb_tree_node_base*)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::ios_base::~ios_base()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to operator new[](unsigned long)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
typeinfo for std::bad_alloc'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base*)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
__cxa_end_catch'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::basic_ofstream<char, std::char_traits >::~basic_ofstream()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_allocate_exception' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::_Rb_tree_increment(std::_Rb_tree_node_base const)'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::bad_alloc::~bad_alloc()' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
atan2'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to vtable for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::ios_base::ios_base()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::cout'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to vtable for std::basic_ios<char, std::char_traits<char> >' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::locale::locale()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
typeinfo for float'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::ostream& std::ostream::_M_insert<double>(double)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
VTT for std::basic_ofstream<char, std::char_traits >'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_guard_release' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::ostream::flush()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to acos' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
typeinfo for double'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to typeinfo for bool' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::ostream::put(char)'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::basic_filebuf<char, std::char_traits >::close()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
vtable for std::basic_streambuf<char, std::char_traits >'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_pure_virtual' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::basic_filebuf<char, std::char_traits >::basic_filebuf()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_throw_bad_array_new_length' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
__dynamic_cast'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to sin' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::__throw_bad_cast()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to vtable for std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
operator delete'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to sqrtf' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::clog'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
vtable for std::bad_alloc'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to tan' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_begin_catch' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
__cxa_rethrow'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_throw' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::__cxx11::basic_string<char, std::char_traits, std::allocator >::rfind(char const*, unsigned long, unsigned long) const'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::locale::~locale()' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
vtable for std::basic_ofstream<char, std::char_traits >'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to cos' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
typeinfo for int'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to vtable for __cxxabiv1::__si_class_type_info' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::basic_filebuf<char, std::char_traits >::basic_filebuf()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to operator new(unsigned long)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::__basic_file::__basic_file()'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__throw_out_of_range_fmt(char const*, ...)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
sqrt'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to sincosf' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
vtable for std::basic_filebuf<char, std::char_traits >'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__throw_length_error(char const*)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
vtable for __cxxabiv1::__class_type_info'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::ostream::operator<<(int)' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to std::__throw_bad_alloc()' /usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to
vtable for __cxxabiv1::__vmi_class_type_info'
/usr/bin/ld: ../../libpmp.so.1.2.1: undefined reference to __cxa_guard_acquire' collect2: error: ld returned 1 exit status make[2]: *** [src/apps/CMakeFiles/mconvert.dir/build.make:85: mconvert] Error 1 make[1]: *** [CMakeFiles/Makefile2:544: src/apps/CMakeFiles/mconvert.dir/all] Error 2 make: *** [Makefile:163: all] Error 2