Open coleged opened 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
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
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.
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::construct<LIO::OutputSysfs, int>(LIO::OutputSysfs*, int&&)':
example.cpp:(.text._ZN9gnu_cxx13new_allocatorIN3LIO11OutputSysfsEE9constructIS2_JiEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO11OutputSysfsEE9constructIS2_JiEEEvPTDpOT0]+0x48): undefined reference to 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 ::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 ::construct<LIO::InputGpioLib, char const (&) [10], int>(LIO::InputGpioLib*, char const (&) [10], int&&)':
example.cpp:(.text._ZN9 gnu_cxx13new_allocatorIN3LIO12InputGpioLibEE9constructIS2_JRA10_KciEEEvPTDpOT0[_ZN9gnu_cxx13new_allocatorIN3LIO12InputGpioLibEE9constructIS2_JRA10_KciEEEvPTDpOT0]+0x5c): undefined reference to ::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
main': example.cpp:(.text+0x3e0): undefined reference to
LIO::DebouncedInput::DebouncedInput(LIO::InputPin&, LIO::BasicTimer&, std::chrono::duration<long long, std::ratio<1ll, 1000ll> >)' /usr/bin/ld: example.cpp:(.text+0x404): undefined reference toLIO::DebouncedInput::setOnCallback(std::function<void ()>)' /usr/bin/ld: example.cpp:(.text+0x434): undefined reference to
LIO::DebouncedInput::setOffCallback(std::function<void ()>)' /usr/bin/ld: example.cpp:(.text+0x470): undefined reference toLIO::InputPin::SetEventCallback(std::function<void (bool)>)' /usr/bin/ld: example.cpp:(.text+0x690): undefined reference to
LIO::DebouncedInput::~DebouncedInput()' /usr/bin/ld: example.cpp:(.text+0x73c): undefined reference toLIO::DebouncedInput::~DebouncedInput()' /usr/bin/ld: example.o: in function
void gnu_cxx::new_allocatorLIO::OutputSysfs::OutputSysfs(unsigned int)' /usr/bin/ld: example.o: in function
voidLIO::InputSysfs::InputSysfs(unsigned int)' /usr/bin/ld: example.o: in function
void __gnu_cxx::new_allocatorLIO::OutputGpioLib::OutputGpioLib(char const*, unsigned int)' /usr/bin/ld: example.o: in function
void gnu_cxx::new_allocatorLIO::InputGpioLib::InputGpioLib(char const*, unsigned int)' /usr/bin/ld: example.o: in function
void gnu_cxx::new_allocator