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. could not add wiringPi to Qt after cross compiling
QtWS25 Last Chance

could not add wiringPi to Qt after cross compiling

Scheduled Pinned Locked Moved Solved Mobile and Embedded
raspberry pi4wiringpicross-compiling
13 Posts 5 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.
  • A amina
    5 Mar 2021, 14:02

    @jsulm I tried it and I got the same error

    INCLUDEPATH += /home/amina/Desktop/test_v1
    
    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 5 Mar 2021, 14:08 last edited by
    #4

    @amina
    Hi
    If you look in
    /home/amina/Desktop/test_v1
    is the .h files in that folder ?
    And not in a sub folder, like include ?

    A 1 Reply Last reply 5 Mar 2021, 14:39
    0
    • M mrjj
      5 Mar 2021, 14:08

      @amina
      Hi
      If you look in
      /home/amina/Desktop/test_v1
      is the .h files in that folder ?
      And not in a sub folder, like include ?

      A Offline
      A Offline
      amina
      wrote on 5 Mar 2021, 14:39 last edited by
      #5

      @mrjj the libwiringPi.so in test_v1
      wiringPi.png

      1 Reply Last reply
      0
      • K Offline
        K Offline
        KH-219Design
        wrote on 5 Mar 2021, 17:47 last edited by
        #6

        (Unless I am missing it and my eyes are too slow...) Your screenshot shows that the '*so' is in the test_v1 folder, but INCLUDEPATH is not for finding the '*so', it is for finding the header file. So as @mrjj asked: what folder has as plain-text file named "wiringPi.h" inside it? That is the folder to add to INCLUDPATH.

        If you can find a copy of this book (either an online PDF copy or any other), then I highly recommend it to all people just getting started in either C or C++. It's less than 100 pages and full of compilation examples that precisely clarify what header files are and what their relationship to '*so' files is.

        Also, while the book title says "GCC", the same principles hold one-for-one when using Clang.

        (Book: An Introduction to GCC, by Brian Gough)

        www.219design.com
        Software | Electrical | Mechanical | Product Design

        1 Reply Last reply
        3
        • K Offline
          K Offline
          KH-219Design
          wrote on 5 Mar 2021, 17:55 last edited by KH-219Design 3 Aug 2021, 16:22
          #7

          Typically, in order to use a *so shared library, you need both the binary library itself (the *so) and the human-readable header files *h.

          In the build configuration, you need to "point to" the location of both those:

          INCLUDEPATH += $${dirforheaders}         # DO NOT COPY THIS LITERALLY. Adjust for your use.
          LIBS += -L$$shadowed($$PWD) -lwiringPi  # DO NOT COPY THIS LITERALLY. Adjust for your use.
          

          There is no technology that allows the build process (the "build toolchain") to extrapolate from the *so where to find the corresponding headers.

          So you almost always need to adjust you INCLUDEPATH and your LIBS.

          You might be thinking of an exceptional case, like... "well how is it that I use zlib.h or locale.h or other well-known header files without figuring out the relevant INCLUDEPATH?" ... This would be a good question! This is due to certain paths being automatically searched.

          The following are common automatically-searched paths:

          /usr/local/include
          /usr/include

          More info: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/cpp/Search-Path.html


          UPDATE: @Pablo-J-Rogina is correct to also mention the particular specific concerns in a cross-compiling environment. I admit that even though "cross compile" is mentioned immediately at the top of the question, I neglected to consider those particulars.

          At minute 23:20 of the video tutorial the video author switches the target to Arm ABI, and that is when he made the "no such file or directory" go away on his machine. Suggesting that on the video author's machine, the header was present in some directory such as "${MY_CROSSCOMPILE_TOOLS}/arm_abi/sysroot/usr/include/"

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          A 1 Reply Last reply 8 Mar 2021, 08:23
          2
          • K KH-219Design
            5 Mar 2021, 17:55

            Typically, in order to use a *so shared library, you need both the binary library itself (the *so) and the human-readable header files *h.

            In the build configuration, you need to "point to" the location of both those:

            INCLUDEPATH += $${dirforheaders}         # DO NOT COPY THIS LITERALLY. Adjust for your use.
            LIBS += -L$$shadowed($$PWD) -lwiringPi  # DO NOT COPY THIS LITERALLY. Adjust for your use.
            

            There is no technology that allows the build process (the "build toolchain") to extrapolate from the *so where to find the corresponding headers.

            So you almost always need to adjust you INCLUDEPATH and your LIBS.

            You might be thinking of an exceptional case, like... "well how is it that I use zlib.h or locale.h or other well-known header files without figuring out the relevant INCLUDEPATH?" ... This would be a good question! This is due to certain paths being automatically searched.

            The following are common automatically-searched paths:

            /usr/local/include
            /usr/include

            More info: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/cpp/Search-Path.html


            UPDATE: @Pablo-J-Rogina is correct to also mention the particular specific concerns in a cross-compiling environment. I admit that even though "cross compile" is mentioned immediately at the top of the question, I neglected to consider those particulars.

            At minute 23:20 of the video tutorial the video author switches the target to Arm ABI, and that is when he made the "no such file or directory" go away on his machine. Suggesting that on the video author's machine, the header was present in some directory such as "${MY_CROSSCOMPILE_TOOLS}/arm_abi/sysroot/usr/include/"

            A Offline
            A Offline
            amina
            wrote on 8 Mar 2021, 08:23 last edited by amina 3 Aug 2021, 08:37
            #8

            @KH-219Design
            Thank you for clarifying! it seems quite obvious

            https://www.youtube.com/watch?v=_R_NA-vubKw
            I was following this tutorial (minute 21:48) he is adding this library and he just copied the .so file
            but I think that wiringPi is installed on his raspberry before he cross compiled Qt so when he created the sysroot directory it contains already the wiringPi.h but the problem is when he added the external library he putted in the INCULUDEPATH the path of his working directory and not the sysroot/usr/include but it worked for him.
            I just copied the /usr/include/wiringPi.h in my working folder and now it is working.
            Thank you !

            P 1 Reply Last reply 8 Mar 2021, 14:16
            1
            • A amina
              8 Mar 2021, 08:23

              @KH-219Design
              Thank you for clarifying! it seems quite obvious

              https://www.youtube.com/watch?v=_R_NA-vubKw
              I was following this tutorial (minute 21:48) he is adding this library and he just copied the .so file
              but I think that wiringPi is installed on his raspberry before he cross compiled Qt so when he created the sysroot directory it contains already the wiringPi.h but the problem is when he added the external library he putted in the INCULUDEPATH the path of his working directory and not the sysroot/usr/include but it worked for him.
              I just copied the /usr/include/wiringPi.h in my working folder and now it is working.
              Thank you !

              P Offline
              P Offline
              Pablo J. Rogina
              wrote on 8 Mar 2021, 14:16 last edited by
              #9

              @amina just in case, when you're working with a cross-compile environment and you later on add a library (.so + .h files) to your device, you're supposed to synchronize again, that is, making those files from the device copied into your sysroot in your host machine.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              A 1 Reply Last reply 9 Mar 2021, 08:52
              4
              • K Offline
                K Offline
                KH-219Design
                wrote on 8 Mar 2021, 16:14 last edited by
                #10

                I'm glad it's working now.

                I noticed in the description of the YouTube video that the video author links to a GitHub repo, and indeed the GitHub repo shows no sign of adding any INCLUDEPATH other than $$PWD.

                You might be able to communicate with the author on GitHub by opening an issue on that repo. It seems unnecessary now. But if anything else comes up you might entertain the idea.

                www.219design.com
                Software | Electrical | Mechanical | Product Design

                A 1 Reply Last reply 9 Mar 2021, 08:55
                1
                • P Pablo J. Rogina
                  8 Mar 2021, 14:16

                  @amina just in case, when you're working with a cross-compile environment and you later on add a library (.so + .h files) to your device, you're supposed to synchronize again, that is, making those files from the device copied into your sysroot in your host machine.

                  A Offline
                  A Offline
                  amina
                  wrote on 9 Mar 2021, 08:52 last edited by
                  #11

                  @Pablo-J-Rogina
                  thank you, I didn't know that. I just need to synchronize the /usr/include and /usr/lib or all the sysroot?

                  rsync -avz pi@192.168.1.31:/usr/include sysroot/usr
                  rsync -avz pi@192.168.1.31:/usr/lib sysroot/usr
                  
                  P 1 Reply Last reply 9 Mar 2021, 14:01
                  0
                  • K KH-219Design
                    8 Mar 2021, 16:14

                    I'm glad it's working now.

                    I noticed in the description of the YouTube video that the video author links to a GitHub repo, and indeed the GitHub repo shows no sign of adding any INCLUDEPATH other than $$PWD.

                    You might be able to communicate with the author on GitHub by opening an issue on that repo. It seems unnecessary now. But if anything else comes up you might entertain the idea.

                    A Offline
                    A Offline
                    amina
                    wrote on 9 Mar 2021, 08:55 last edited by
                    #12

                    @KH-219Design said in could not add wiringPi to Qt after cross compiling:

                    You might be able to communicate with the author on GitHub by opening an issue on that repo. It seems unnecessary now. But if anything else comes up you might entertain the idea.

                    okay i will consider it next time, thank you

                    1 Reply Last reply
                    0
                    • A amina
                      9 Mar 2021, 08:52

                      @Pablo-J-Rogina
                      thank you, I didn't know that. I just need to synchronize the /usr/include and /usr/lib or all the sysroot?

                      rsync -avz pi@192.168.1.31:/usr/include sysroot/usr
                      rsync -avz pi@192.168.1.31:/usr/lib sysroot/usr
                      
                      P Offline
                      P Offline
                      Pablo J. Rogina
                      wrote on 9 Mar 2021, 14:01 last edited by
                      #13

                      @amina said in could not add wiringPi to Qt after cross compiling:

                      I just need to synchronize the /usr/include and /usr/lib or all the sysroot?

                      It depends on the changes you do, and if you know exactly what folders were modified.
                      Some people perform the sync for the whole sysroot just in case.

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      1

                      13/13

                      9 Mar 2021, 14:01

                      • Login

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