Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Add wiringPi to cross compile
Forum Updated to NodeBB v4.3 + New Features

Add wiringPi to cross compile

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 7 Posters 3.1k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    Creatorczyk
    wrote on last edited by
    #1

    Hi,

    I configured environment for cross compile for my RaspberryPi 3B. I created project which use wiringPi library.
    My pro file:

    QT -= gui
    
    CONFIG += c++11 console
    CONFIG -= app_bundle
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    INCLUDEPATH += /home/john/raspi/sysroot/usr/include/
    
    LIBS += -L"/home/john/raspi/sysroot/usr/lib"
    LIBS += -lwiringPi
    
    HEADERS +=
           wiringPi.h
    
    SOURCES += \
            main.cpp
    
    target.path = home/pi/
    #QtProjects/testRpi
    INSTALLS += target
    
    # Default rules for deployment.
    #qnx: target.path = /tmp/$${TARGET}/bin
    #else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    My main.cpp

    #include <QCoreApplication>
    #include <QDebug>
    #include <wiringPi.h>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        wiringPiSetup();
    
        return a.exec();
    }
    

    But when I try build project i get error:
    error: use of undeclared identifier 'wiringPiSetup'

    What can I do to fix that?

    jsulmJ Pablo J. RoginaP JonBJ 3 Replies Last reply
    0
    • C Creatorczyk

      Hi,

      I configured environment for cross compile for my RaspberryPi 3B. I created project which use wiringPi library.
      My pro file:

      QT -= gui
      
      CONFIG += c++11 console
      CONFIG -= app_bundle
      
      DEFINES += QT_DEPRECATED_WARNINGS
      
      INCLUDEPATH += /home/john/raspi/sysroot/usr/include/
      
      LIBS += -L"/home/john/raspi/sysroot/usr/lib"
      LIBS += -lwiringPi
      
      HEADERS +=
             wiringPi.h
      
      SOURCES += \
              main.cpp
      
      target.path = home/pi/
      #QtProjects/testRpi
      INSTALLS += target
      
      # Default rules for deployment.
      #qnx: target.path = /tmp/$${TARGET}/bin
      #else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      

      My main.cpp

      #include <QCoreApplication>
      #include <QDebug>
      #include <wiringPi.h>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          wiringPiSetup();
      
          return a.exec();
      }
      

      But when I try build project i get error:
      error: use of undeclared identifier 'wiringPiSetup'

      What can I do to fix that?

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

      @Creatorczyk said in Add wiringPi to cross compile:

      #include <wiringPi.h>

      So, it does not complain about this header (it is found?)?
      Can you check the content of that header file?

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

      1 Reply Last reply
      1
      • G Offline
        G Offline
        GoRo3
        wrote on last edited by
        #3

        Hi there!

        I think in .pro file you have to setup all include paths and library paths in relation to original root path on device and have correct setup of kit and sysroot path in "Kit" option on Qt Creator side.

        In my project.pro file i have added only:

        LIBS += -L/usr/local/lib/libwiringPi.so -lwiringPi
        

        When you have correct kit setup (with sysroot) in Qt Creator options, Qt will find header file by himself. If you want to check full pro file take look on my gitlab page: https://gitlab.com/GoRo3/rpibuttons/-/blob/master/Rpi3_Buttons.pro

        Best regards!
        GoRo3

        JonBJ 1 Reply Last reply
        0
        • G GoRo3

          Hi there!

          I think in .pro file you have to setup all include paths and library paths in relation to original root path on device and have correct setup of kit and sysroot path in "Kit" option on Qt Creator side.

          In my project.pro file i have added only:

          LIBS += -L/usr/local/lib/libwiringPi.so -lwiringPi
          

          When you have correct kit setup (with sysroot) in Qt Creator options, Qt will find header file by himself. If you want to check full pro file take look on my gitlab page: https://gitlab.com/GoRo3/rpibuttons/-/blob/master/Rpi3_Buttons.pro

          Best regards!
          GoRo3

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @GoRo3
          But the OP is not reporting that the included file is not found (else he would undoubtedly have said so...), he is reporting "use of undeclared identifier"....

          1 Reply Last reply
          0
          • ad1170A Offline
            ad1170A Offline
            ad1170
            wrote on last edited by
            #5

            Try to add the *Dev version.

            LIBS += -L"path_to_raspi_sysroot"/usr/lib/ -lwiringPiDev

            It seems that your Lib path does not refer to the raspi sysroot.

            /usr/local/lib is a path on your host if you cross compile.

            1 Reply Last reply
            0
            • C Creatorczyk

              Hi,

              I configured environment for cross compile for my RaspberryPi 3B. I created project which use wiringPi library.
              My pro file:

              QT -= gui
              
              CONFIG += c++11 console
              CONFIG -= app_bundle
              
              DEFINES += QT_DEPRECATED_WARNINGS
              
              INCLUDEPATH += /home/john/raspi/sysroot/usr/include/
              
              LIBS += -L"/home/john/raspi/sysroot/usr/lib"
              LIBS += -lwiringPi
              
              HEADERS +=
                     wiringPi.h
              
              SOURCES += \
                      main.cpp
              
              target.path = home/pi/
              #QtProjects/testRpi
              INSTALLS += target
              
              # Default rules for deployment.
              #qnx: target.path = /tmp/$${TARGET}/bin
              #else: unix:!android: target.path = /opt/$${TARGET}/bin
              !isEmpty(target.path): INSTALLS += target
              

              My main.cpp

              #include <QCoreApplication>
              #include <QDebug>
              #include <wiringPi.h>
              
              int main(int argc, char *argv[])
              {
                  QCoreApplication a(argc, argv);
              
                  wiringPiSetup();
              
                  return a.exec();
              }
              

              But when I try build project i get error:
              error: use of undeclared identifier 'wiringPiSetup'

              What can I do to fix that?

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @Creatorczyk said in Add wiringPi to cross compile:

              I configured environment for cross compile for my RaspberryPi 3B. I created project which use wiringPi library.

              Have you cross-compiled the wiringPi library?
              or have you installed directly in your RPi device?

              One way or the other, are you positive that the wiringPi library and header files are synchronized into your sysroot folder in the host machine?

              Having a Yes for answer to that question, please check that file wiringPi.h is available in the path stated in your INCLUDEPATH setting from your .pro file.

              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
              0
              • C Offline
                C Offline
                Creatorczyk
                wrote on last edited by
                #7

                I checked your suggestions and I was unable to solve the problem.

                @jsulm @JonB
                The library "libwiringPi.so" exist in path:
                /home/john/raspi/sysroot/usr/lib on the PC
                /usr/lib on the RPI

                and file "wiringPi.h" exist in path:
                /home/john/raspi/sysroot/usr/include on the PC
                /usr/include on the RPI

                Maybe it is important, but while building the application I don't get any errors in the pro file. (I made them especially for the test and it did not detect)

                @GoRo3 I tried and it did not help. But my libwiringPi.so is in the path /usr/lib on the RPi, so i try:

                INCLUDEPATH += /home/john/raspi/sysroot/usr/include/
                LIBS += -L/usr/lib/libwiringPi.so -lwiringPi

                I set up everything just like in this tutorial:
                https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/

                I have WARNING like
                "/home/john/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc" is used by qmake, but
                "/home/john/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/bin/gcc" is configured in the kit.
                Please update your kit (RaspberryPi3) or choose a mkspec for qmake that matches your target environment better.

                But application for "Hello World" works

                @ad1170 your solution doesn't work.
                INCLUDEPATH += /home/john/raspi/sysroot/usr/include/
                LIBS += -L/home/pi/usr/lib/ -lwiringPiDev

                1 Reply Last reply
                0
                • C Creatorczyk

                  Hi,

                  I configured environment for cross compile for my RaspberryPi 3B. I created project which use wiringPi library.
                  My pro file:

                  QT -= gui
                  
                  CONFIG += c++11 console
                  CONFIG -= app_bundle
                  
                  DEFINES += QT_DEPRECATED_WARNINGS
                  
                  INCLUDEPATH += /home/john/raspi/sysroot/usr/include/
                  
                  LIBS += -L"/home/john/raspi/sysroot/usr/lib"
                  LIBS += -lwiringPi
                  
                  HEADERS +=
                         wiringPi.h
                  
                  SOURCES += \
                          main.cpp
                  
                  target.path = home/pi/
                  #QtProjects/testRpi
                  INSTALLS += target
                  
                  # Default rules for deployment.
                  #qnx: target.path = /tmp/$${TARGET}/bin
                  #else: unix:!android: target.path = /opt/$${TARGET}/bin
                  !isEmpty(target.path): INSTALLS += target
                  

                  My main.cpp

                  #include <QCoreApplication>
                  #include <QDebug>
                  #include <wiringPi.h>
                  
                  int main(int argc, char *argv[])
                  {
                      QCoreApplication a(argc, argv);
                  
                      wiringPiSetup();
                  
                      return a.exec();
                  }
                  

                  But when I try build project i get error:
                  error: use of undeclared identifier 'wiringPiSetup'

                  What can I do to fix that?

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #8

                  @Creatorczyk said in Add wiringPi to cross compile:

                  But when I try build project i get error:
                  error: use of undeclared identifier 'wiringPiSetup'

                  If this is indeed the error message you get when trying to compile your main.cpp which has

                  #include <wiringPi.h>
                  ...
                  wiringPiSetup();
                  

                  and there are not other errors, then I don't understand how the half the questions about libraries or whether the included file exists or not are relevant....

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    BabbRust
                    wrote on last edited by BabbRust
                    #9

                    Hi....The instruction say that is significant make a neighborhood duplicate of the header documents and of the libraries present on the rough and invigorate the duplicate each time it's anything but another library or another header record. There are the istruction for do that.

                    Now you should design the Eclipse project for utilize the Wiringpi.h and the wiringpi.so library document.

                    https://www.7pcb.com/

                    jsulmJ 1 Reply Last reply
                    0
                    • B BabbRust

                      Hi....The instruction say that is significant make a neighborhood duplicate of the header documents and of the libraries present on the rough and invigorate the duplicate each time it's anything but another library or another header record. There are the istruction for do that.

                      Now you should design the Eclipse project for utilize the Wiringpi.h and the wiringpi.so library document.

                      https://www.7pcb.com/

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

                      @BabbRust It's not clear what you mean. Can you please explain better?

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

                      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