perimeno / LIO

GPIO handling in C++
MIT License
19 stars 4 forks source link

Missing library symbols #6

Open coleged opened 3 years ago

coleged commented 3 years ago

I built the lib on Raspian - hand installed includes and libs in /usr/local

My attempts to compile example.cpp report missing symbols when linked with either/or/both LIOlib & LIOLinuxlib

i.e. g++ -L/usr/local/lib -lLIOLinuxlib -lLIOlib example.o \ -o example /usr/bin/ld: example.o: in function main': example.cpp:(.text+0x3e0): undefined reference toLIO::DebouncedInput::DebouncedInput(LIO::InputPin&, LIO::BasicTimer&, std::chrono::duration<long long, std::ratio<1ll, 1000ll> >)' /usr/bin/ld: example.cpp:(.text+0x404): undefined reference to LIO::DebouncedInput::setOnCallback(std::function<void ()>)' /usr/bin/ld: example.cpp:(.text+0x434): undefined reference toLIO::DebouncedInput::setOffCallback(std::function<void ()>)' /usr/bin/ld: example.cpp:(.text+0x470): undefined reference to LIO::InputPin::SetEventCallback(std::function<void (bool)>)' /usr/bin/ld: example.cpp:(.text+0x690): undefined reference toLIO::DebouncedInput::~DebouncedInput()' /usr/bin/ld: example.cpp:(.text+0x73c): undefined reference to LIO::DebouncedInput::~DebouncedInput()' /usr/bin/ld: example.o: in functionvoid gnu_cxx::new_allocator::construct<LIO::OutputSysfs, int>(LIO::OutputSysfs*, int&&)': example.cpp:(.text._ZN9gnu_cxx13new_allocatorIN3LIO11OutputSysfsEE9constructIS2_JiEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO11OutputSysfsEE9constructIS2_JiEEEvPTDpOT0]+0x48): undefined reference to LIO::OutputSysfs::OutputSysfs(unsigned int)' /usr/bin/ld: example.o: in functionvoid gnu_cxx::new_allocator::construct<LIO::InputSysfs, int>(LIO::InputSysfs, int&&)': example.cpp:(.text._ZN9gnu_cxx13new_allocatorIN3LIO10InputSysfsEE9constructIS2_JiEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO10InputSysfsEE9constructIS2_JiEEEvPTDpOT0]+0x48): undefined reference to LIO::InputSysfs::InputSysfs(unsigned int)' /usr/bin/ld: example.o: in functionvoid __gnu_cxx::new_allocator::construct<LIO::OutputGpioLib, char const (&) [10], int>(LIO::OutputGpioLib, char const (&) [10], int&&)': example.cpp:(.text._ZN9gnu_cxx13new_allocatorIN3LIO13OutputGpioLibEE9constructIS2_JRA10_KciEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO13OutputGpioLibEE9constructIS2_JRA10_KciEEEvPTDpOT0]+0x5c): undefined reference to LIO::OutputGpioLib::OutputGpioLib(char const*, unsigned int)' /usr/bin/ld: example.o: in functionvoid gnu_cxx::new_allocator::construct<LIO::InputGpioLib, char const (&) [10], int>(LIO::InputGpioLib*, char const (&) [10], int&&)': example.cpp:(.text._ZN9gnu_cxx13new_allocatorIN3LIO12InputGpioLibEE9constructIS2_JRA10_KciEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO12InputGpioLibEE9constructIS2_JRA10_KciEEEvPTDpOT0]+0x5c): undefined reference to LIO::InputGpioLib::InputGpioLib(char const*, unsigned int)' /usr/bin/ld: example.o: in functionvoid gnu_cxx::new_allocator::construct(LIO::SoftTimer*)': example.cpp:(.text._ZN9gnu_cxx13new_allocatorIN3LIO9SoftTimerEE9constructIS2_JEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO9SoftTimerEE9constructIS2_JEEEvPTDpOT0]+0x2c): undefined reference to `LIO::SoftTimer::SoftTimer()' collect2: error: ld returned 1 exit status make: *** [Makefile:35: example] Error 1

coleged commented 3 years ago

Update. So, blundering about with this, I decided to compile up one mondo shared library from libLIOlib.a and libLIOLinuxlib.a (called it libLIO.so).... some improvement. Now all I get is:

ecole@gpio:~/src/LIO_test $ make g++ -std=c++14 -pthread -I/usr/local/include -c example.cpp -o example.o g++ -L/usr/local/lib -lpthread -lLIO example.o \ -o example /usr/bin/ld: /usr/local/lib/libLIO.so: undefined reference to __atomic_load_8' /usr/bin/ld: /usr/local/lib/libLIO.so: undefined reference to__atomic_store_8' collect2: error: ld returned 1 exit status make: *** [Makefile:35: example] Error 1

coleged commented 3 years ago

FIXED - for now at least ;-) Learnt a bit more in the process too.

ecole@gpio:~/src/LIO_test $ make g++ -std=c++14 -pthread -I/usr/local/include -c example.cpp -o example.o g++ -L/usr/local/lib -lpthread -latomic -lLIO example.o \ -o example

perimeno commented 3 years ago

Hi, To be honest, I never tried to to build the components manulally. I always used CMake to build and link the project. It will add the necessary linker flags (pthread/atomic) automatically.