Home > Blockchain >  QtCreator does not search sysroot/usr/include for header files even if the path was added to CMakeLi
QtCreator does not search sysroot/usr/include for header files even if the path was added to CMakeLi

Time:08-06

I was cross-compiling an application for Raspberry Pi with libgpiod. The cross-compilation environment has been successfully set up according to this guide: https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi. I have installed the libgpiod* libraries on RPi and rsync those files back to the host qt6pi/sysroot directory. The library was added to the project's CMakeList.txt file by:

add_library(libgpiod ~/qt6pi-sysroot/sysroot/usr/lib/aarch64-linux-gnu/libgpiod.so)
target_include_directories(libgpiod INTERFACE ~/qt6pi-sysroot/sysroot/usr/include)
target_link_libraries(testProj PRIVATE libgpiod)

My problem is that even if that target_include_directories was added, Qt Creator still complains that the header file <gpiod.h> was not found. And the weird thing is when I moved the gpdiod.h header to other locations and accordingly change the above command, everything works just fine. It seems like the sysroot/usr/include path was overwritten by /usr/include when Creator is searching for header files.

Could someone help me out with how to properly add a third-party library to the Qt project using CMake? Thanks a lot!!!

CodePudding user response:

IMHO it's a typo.

target_include_directories(libgpiod ...

should be

target_include_directories(testProj ...

CodePudding user response:

This wiki article from CMake Wiki might help to answer your question. Try to also restart Qt Creator after linking the library to your CMakeLists.txt.

  • Related