psychogenic / gattlibpp

GattLib++ is a C++ wrapper around the gattlib BLE GATT access library
GNU General Public License v3.0
21 stars 3 forks source link

can't build example #3

Open TiboGabriels opened 2 years ago

TiboGabriels commented 2 years ago

im trying to run the example on a rpi 4b, installed all libraries as in readme, this is the error i'm getting:

pi@PlantIo:~/Code/raspberry-central $ sudo g++ -o build/PlantIo src/main.cpp
/usr/bin/ld: /tmp/ccKRoxSq.o: in function `main':
main.cpp:(.text+0x254): undefined reference to `Gattlib::BLECentral::getInstance()'
/usr/bin/ld: main.cpp:(.text+0x2a4): undefined reference to `Gattlib::BLECentral::enable(std::function<void ()>, std::function<void ()>)'
/usr/bin/ld: main.cpp:(.text+0x2dc): undefined reference to `Gattlib::BLECentral::getInstance()'
/usr/bin/ld: main.cpp:(.text+0x2e8): undefined reference to `Gattlib::BLECentral::processAsync()'
/usr/bin/ld: main.cpp:(.text+0x330): undefined reference to `Gattlib::BLECentral::getInstance()'
/usr/bin/ld: main.cpp:(.text+0x33c): undefined reference to `Gattlib::BLECentral::shutdown()'
/usr/bin/ld: /tmp/ccKRoxSq.o: in function `onConnect(Gattlib::Discovery::DiscDeviceStruct const&)':
main.cpp:(.text+0x54c): undefined reference to `Gattlib::BLECentral::getInstance()'
/usr/bin/ld: main.cpp:(.text+0x564): undefined reference to `Gattlib::BLECentral::characteristicsFor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: main.cpp:(.text+0x664): undefined reference to `Gattlib::Characteristic::CharDetailsStruct::supportsReads() const'
/usr/bin/ld: main.cpp:(.text+0x6a0): undefined reference to `Gattlib::Characteristic::CharDetailsStruct::supportsWrites() const'
/usr/bin/ld: main.cpp:(.text+0x6dc): undefined reference to `Gattlib::Characteristic::CharDetailsStruct::supportSubscriptions() const'
/usr/bin/ld: /tmp/ccKRoxSq.o: in function `useEnabledBLECentral(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda()#1}::operator()() const':
main.cpp:(.text+0x97c): undefined reference to `Gattlib::BLECentral::stopScan(std::function<void ()>, std::function<void ()>)'
/usr/bin/ld: /tmp/ccKRoxSq.o: in function `useEnabledBLECentral(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(Gattlib::Discovery::DiscDeviceStruct const&)#2}::operator()(Gattlib::Discovery::DiscDeviceStruct const&) const::{lambda()#1}::operator()() const':
main.cpp:(.text+0xaf4): undefined reference to `Gattlib::BLECentral::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>, std::function<void ()>)'
/usr/bin/ld: /tmp/ccKRoxSq.o: in function `useEnabledBLECentral(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(Gattlib::Discovery::DiscDeviceStruct const&)#2}::operator()(Gattlib::Discovery::DiscDeviceStruct const&) const':
main.cpp:(.text+0xda0): undefined reference to `Gattlib::BLECentral::stopScan(std::function<void ()>, std::function<void ()>)'
/usr/bin/ld: /tmp/ccKRoxSq.o: in function `useEnabledBLECentral(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
main.cpp:(.text+0xeb4): undefined reference to `Gattlib::BLECentral::getInstance()'
/usr/bin/ld: main.cpp:(.text+0xf88): undefined reference to `Gattlib::BLECentral::scan(unsigned short, std::function<void ()>, std::function<void (Gattlib::Discovery::DiscDeviceStruct const&)>, std::function<void ()>)'
collect2: error: ld returned 1 exit status

I tried with or without using an include directory but neither helped

psychogenic commented 2 years ago

Greets, Looks a lot like linker errors, as in you need to tell g++ to link the libs... Easiest approach would probably be to re-use or replicate the CMakelists.txt stuff and use cmake for compilation and linking. Maybe just build one of the samples. If that works, steal the -lwhatever lines that are used during compile.