try -lgpiod -lpthread -lgpiodcxx
Here is a cmake snippet that I just use by default on gpio stuff.
Your code is fine, just ran it here and it is just using gpiodcxx
Here is the complete cmake
So, at this point you might not have the libraries installed correctly.
Look for this
Here is a trail of bread crumbs if you want to try the cmake:
when you execute the cmake make sure you have .. after it.
Here is a cmake snippet that I just use by default on gpio stuff.
Code:
# Link librariestarget_link_libraries(${PROJECT_NAME} pthread gpiod gpiodcxx)
Code:
/tmp/helloworld/cmake-build-debug-bbbi4/helloworldHello Worldgpiochip0gpiochip1gpiochip2gpiochip3Process finished with exit code 0
Code:
cmake_minimum_required(VERSION 3.10)project(helloworld)set(CMAKE_CXX_STANDARD 20)add_executable(helloworld main.cpp)target_link_libraries(${PROJECT_NAME} gpiodcxx)
Code:
$sudo apt install libgpiod-dev libgpiod-doc gpiod
Code:
$ dpkg -L libgpiod-dev | grep libgpiodcxx.so
Code:
fred@eng-dev2:~/CLionProjects/a-lgpiod$ cd helloworld/fred@eng-dev2:~/CLionProjects/a-lgpiod/helloworld$ lscmake-build-debug cmake-build-debug-bbbi4 CMakeLists.txt main.cppfred@eng-dev2:~/CLionProjects/a-lgpiod/helloworld$ mkdir buildfred@eng-dev2:~/CLionProjects/a-lgpiod/helloworld$ cd build/fred@eng-dev2:~/CLionProjects/a-lgpiod/helloworld/build$ cmake ..-- The C compiler identification is GNU 11.4.0-- The CXX compiler identification is GNU 11.4.0-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working C compiler: /usr/bin/cc - skipped-- Detecting C compile features-- Detecting C compile features - done-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - done-- Check for working CXX compiler: /usr/bin/c++ - skipped-- Detecting CXX compile features-- Detecting CXX compile features - done-- Configuring done-- Generating done-- Build files have been written to: /home/fred/CLionProjects/a-lgpiod/helloworld/buildfred@eng-dev2:~/CLionProjects/a-lgpiod/helloworld/build$ make[ 50%] Building CXX object CMakeFiles/helloworld.dir/main.cpp.o[100%] Linking CXX executable helloworld[100%] Built target helloworldfred@eng-dev2:~/CLionProjects/a-lgpiod/helloworld/build$
Statistics: Posted by foxsquirrel — Wed Aug 28, 2024 11:45 pm