fatal error: wiringPi.h: No such file or directory

  c++, cmake, raspberry-pi

Learning cmake for use with CLion. I have a raspberry pi project and I’m trying to bring in wiringPi library on my Ubuntu box. Here’s my build results.

====================[ Build | rookery_exe | Raspberry Pi Release ]==============
/snap/bin/cmake --build /tmp/tmp.UNnm1OGKQ2/cmake-build-raspberry-pi-release --target rookery_exe -- -j 12
[  9%] Building CXX object src/core/CMakeFiles/rookery_core.dir/Lights.cpp.o
/tmp/tmp.UNnm1OGKQ2/src/core/Lights.cpp:1:10: fatal error: wiringPi.h: No such file or directory
    1 | #include <wiringPi.h>
      |          ^~~~~~~~~~~~
compilation terminated.
gmake[3]: *** [src/core/CMakeFiles/rookery_core.dir/build.make:124: src/core/CMakeFiles/rookery_core.dir/Lights.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:203: src/core/CMakeFiles/rookery_core.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:236: src/exe/CMakeFiles/rookery_exe.dir/rule] Error 2
gmake: *** [Makefile:182: rookery_exe] Error 2

I installed both libwiringpi and libwiringpi-dev. When I looked, here’s the result of my find command:

[email protected]:/usr$ find -name *wiringPi*
./lib/x86_64-linux-gnu/libwiringPiDev.so.2
./lib/x86_64-linux-gnu/libwiringPiDev.so
./lib/x86_64-linux-gnu/libwiringPi.so.2.50
./lib/x86_64-linux-gnu/libwiringPi.so
./lib/x86_64-linux-gnu/libwiringPi.so.2
./lib/x86_64-linux-gnu/libwiringPiDev.so.2.50
./include/wiringPi.h
./include/wiringPiSPI.h
./include/wiringPiI2C.h
[email protected]:/usr$ 

My cmake file is as follows:

cmake_minimum_required(VERSION 3.19)

project(rookery_core)

file(GLOB_RECURSE SOURCES LIST_DIRECTORIES true *.h *.cpp)

set(SOURCES ${SOURCES})

set(CMAKE_CXX_STANDARD 20)

add_library(${CMAKE_PROJECT_NAME}_core STATIC ${SOURCES})

target_include_directories(${CMAKE_PROJECT_NAME}_core INTERFACE /usr/include)
target_link_directories(${CMAKE_PROJECT_NAME}_core INTERFACE /usr/lib/x86_64-linux-gnu)

find_library(LIB_WIRING_PI libwiringPi HINTS /usr/lib/x86_64-linux-gnu)

Not sure where to go with this. I took a whole udemy class on cmake.

Source: Windows Questions C++

LEAVE A COMMENT