Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QtCreator does not search sysroot/usr/include for header files even if the path was added to CMakeLists
Forum Updated to NodeBB v4.3 + New Features

QtCreator does not search sysroot/usr/include for header files even if the path was added to CMakeLists

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wenjiayu
    wrote on last edited by
    #1

    I was cross compiling an application for Raspberry Pi with libgpiod. The cross compilation environment has been successfully set up according to this guid: 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 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, every thing 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 about how to properly add a third party library to Qt project using CMake.
    Thanks a lot!!!

    1 Reply Last reply
    1
    • U Offline
      U Offline
      uraihan
      wrote on last edited by uraihan
      #2

      Hi!

      I've been fiddling around with this issue and successfully reproduced your problem. Long story short, I found this CMake Wiki article and it helped quite a lot. The following CMake commands works for me:

      add_library(libgpiod SHARED IMPORTED)
      set_target_properties(libgpiod PROPERTIES IMPORTED_LOCATION /home/uraihan/rpi-sysroot/usr/lib/aarch64-linux-gnu/libgpiod.so)
      target_include_directories(libgpiod INTERFACE /home/uraihan/rpi-sysroot/usr/include)
      target_link_libraries(demo_app PRIVATE libgpiod)
      

      When I tried this yesterday for the first time, Qt Creator also thrown a warning that the gpiod.h file is not found every time I'm declaring #include <gpiod.h>. The next day, I found that Qt Creator is no longer complaining about that anymore and I'm able to get the Qt Creator features for the library (autocomplete and all that stuff). So I'd suggest try restarting Qt Creator if you still get the warning after adding the external library to CMakeLists.txt.

      Hope it helps!

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wenjiayu
        wrote on last edited by
        #3

        Thanks for your answer. Unfortunately, this did not work for me. It seems that the problem is about the path "~/qt6pi-sysroot/sysroot/usr/include" itself, since when I use the commands I have posted, everything works just fine with any other directories other than this one.
        I worked this around by
        target_include_directories(libgpiod INTERFACE ~/qt6pi-sysroot/sysroot/usr)
        and then
        #include <include/gpiod.h>

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved