Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5229

C/C++ • Re: C++: Linking failing on Pi 1 B+ for class members, but the same code compiles on Ubuntu

$
0
0
Does "mylibrary" use functions from "library1"? Have you tried changing the order of the libraries on the command line?

From "g++ test.cpp -o test -llibrary1 -lmylibrary" to "g++ test.cpp -o test -lmylibrary -llibrary1"

Try just compiling "test.cpp" and looking at the symbol table as follows

Code:

% g++ -c test.cxx -o test.o% nm -C test.o         U __aeabi_atexit         U __aeabi_unwind_cpp_pr1         U __dso_handle00000128 t _GLOBAL__sub_I_main00000000 T main000000c4 t __static_initialization_and_destruction_0(int, int)00000000 r testarr         U MyClass::test()         U MyClass::MyClass(int, int)         U std::ostream::operator<<(int)         U std::ostream::operator<<(std::ostream& (*)(std::ostream&))         U std::ios_base::Init::Init()         U std::ios_base::Init::~Init()         U std::cout         U std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)00000000 b std::__ioinit         U std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
Do the same with the library

Code:

% nm -C /usr/local/lib/libmylibrary.amylibrary.o:00000000 r testarr00000088 T MyClass::test()00000000 T MyClass::MyClass(int, int)0000003c T MyClass::MyClass(int, int, int)00000000 T MyClass::MyClass(int, int)0000003c T MyClass::MyClass(int, int, int)

Statistics: Posted by AndyD — Mon Jun 17, 2024 2:52 am



Viewing all articles
Browse latest Browse all 5229

Trending Articles