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.
  • aminaA Offline
    aminaA Offline
    amina
    wrote on last edited by
    #1

    Hello,

    I cross compiled Qt for raspberry pi 4. I am working on a lite version of OS
    and before cross compiling I didn't check if wiring pi was installed or not ..

    Now that I need these library to start using GIOP pins, I couldn't add it.
    so this is what I did to install it:

    on my raspberry pi :

    sudo apt update
    sudo apt full-upgrade
    sudo apt-get install wiringpi
    cd
    mkdir wiringPi
    cd wiringPi
    pi@raspberrypi:~/wiringPi $ wget https://project-downloads.drogon.net/wiringpi-latest.deb
    sudo dpkg -i wiringpi-latest.deb
    

    after that on my ubuntu and in my working folder (the one that contains the source code of my Qt application ) I added the libwiringPi.so
    scp pi@192.168.1.31:/usr/lib/libwiringPi.so .

    after that I tried to add it to my project as an external library
    so now my .pro file looks like this

    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /home/pi/$${TARGET}
    !isEmpty(target.path): INSTALLS += target
    
    DISTFILES +=
    
    HEADERS += \
        contacteur.h \
        capteur.h
    
    unix:!macx: LIBS += -L$$PWD/./ -lwiringPi
    
    INCLUDEPATH += $$PWD/.
    DEPENDPATH += $$PWD/.
    

    and when including #include<wiringPi.h>

    an error shows up no such file or directory

    is there any way to fix this or should I do the cross compilation again ?

    Thank you for helping

    jsulmJ 1 Reply Last reply
    0
    • KH-219DesignK Offline
      KH-219DesignK Offline
      KH-219Design
      wrote on last edited by KH-219Design
      #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

      aminaA 1 Reply Last reply
      2
      • aminaA amina

        Hello,

        I cross compiled Qt for raspberry pi 4. I am working on a lite version of OS
        and before cross compiling I didn't check if wiring pi was installed or not ..

        Now that I need these library to start using GIOP pins, I couldn't add it.
        so this is what I did to install it:

        on my raspberry pi :

        sudo apt update
        sudo apt full-upgrade
        sudo apt-get install wiringpi
        cd
        mkdir wiringPi
        cd wiringPi
        pi@raspberrypi:~/wiringPi $ wget https://project-downloads.drogon.net/wiringpi-latest.deb
        sudo dpkg -i wiringpi-latest.deb
        

        after that on my ubuntu and in my working folder (the one that contains the source code of my Qt application ) I added the libwiringPi.so
        scp pi@192.168.1.31:/usr/lib/libwiringPi.so .

        after that I tried to add it to my project as an external library
        so now my .pro file looks like this

        # Default rules for deployment.
        qnx: target.path = /tmp/$${TARGET}/bin
        else: unix:!android: target.path = /home/pi/$${TARGET}
        !isEmpty(target.path): INSTALLS += target
        
        DISTFILES +=
        
        HEADERS += \
            contacteur.h \
            capteur.h
        
        unix:!macx: LIBS += -L$$PWD/./ -lwiringPi
        
        INCLUDEPATH += $$PWD/.
        DEPENDPATH += $$PWD/.
        

        and when including #include<wiringPi.h>

        an error shows up no such file or directory

        is there any way to fix this or should I do the cross compilation again ?

        Thank you for helping

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

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

        is there any way to fix this or should I do the cross compilation again ?

        Yes: add the folder containing WiringPi header files to INCLUDEPATH

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        aminaA 1 Reply Last reply
        0
        • jsulmJ jsulm

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

          is there any way to fix this or should I do the cross compilation again ?

          Yes: add the folder containing WiringPi header files to INCLUDEPATH

          aminaA Offline
          aminaA Offline
          amina
          wrote on last edited by amina
          #3

          @jsulm I tried it and I got the same error

          INCLUDEPATH += /home/amina/Desktop/test_v1
          
          mrjjM 1 Reply Last reply
          0
          • aminaA amina

            @jsulm I tried it and I got the same error

            INCLUDEPATH += /home/amina/Desktop/test_v1
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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 ?

            aminaA 1 Reply Last reply
            0
            • mrjjM mrjj

              @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 ?

              aminaA Offline
              aminaA Offline
              amina
              wrote on last edited by
              #5

              @mrjj the libwiringPi.so in test_v1
              wiringPi.png

              1 Reply Last reply
              0
              • KH-219DesignK Offline
                KH-219DesignK Offline
                KH-219Design
                wrote on 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
                • KH-219DesignK Offline
                  KH-219DesignK Offline
                  KH-219Design
                  wrote on last edited by KH-219Design
                  #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

                  aminaA 1 Reply Last reply
                  2
                  • KH-219DesignK KH-219Design

                    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/"

                    aminaA Offline
                    aminaA Offline
                    amina
                    wrote on last edited by amina
                    #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 !

                    Pablo J. RoginaP 1 Reply Last reply
                    1
                    • aminaA amina

                      @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 !

                      Pablo J. RoginaP Offline
                      Pablo J. RoginaP Offline
                      Pablo J. Rogina
                      wrote on 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

                      aminaA 1 Reply Last reply
                      4
                      • KH-219DesignK Offline
                        KH-219DesignK Offline
                        KH-219Design
                        wrote on 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

                        aminaA 1 Reply Last reply
                        1
                        • Pablo J. RoginaP Pablo J. Rogina

                          @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.

                          aminaA Offline
                          aminaA Offline
                          amina
                          wrote on 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
                          
                          Pablo J. RoginaP 1 Reply Last reply
                          0
                          • KH-219DesignK KH-219Design

                            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.

                            aminaA Offline
                            aminaA Offline
                            amina
                            wrote on 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
                            • aminaA amina

                              @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
                              
                              Pablo J. RoginaP Offline
                              Pablo J. RoginaP Offline
                              Pablo J. Rogina
                              wrote on 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

                              • Login

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