How to set up RPi WiringPi library and other libs for Qt cross-compile
-
In an old topic I found this interesting reply from @SGaist (post/381375):
snip ... install the development package on the RPi and sync the sysroot you use when cross-compiling your application ...
I got cross-compiling for RPi2 & RPi3 to work for Qt 5.10.1 using the guide in wiki.qt.io/RaspberryPi2EGLFS and have then been trying to get the wirinpi lib to function too. I have tried to sync the needed stuff back to the host from RPi using rsync but haven't got things to work. Can someone please clarify what to do for the sysroot folder (if anything) to get all the wiringpi libraries in proper places. This is a list of the wiringpi related stuff on RPi:
pi@rpi2:/ $ sudo find -name wiri
./home/pi/sysroot/usr/lib/libwiringPiDev.so
./home/pi/sysroot/usr/lib/libwiringPi.so
./home/pi/wiringPi
./home/pi/wiringPi/wiringPiD
./home/pi/wiringPi/wiringPiD/wiringpid.c
./home/pi/wiringPi/debian/libwiringpi2.shlibs
./home/pi/wiringPi/debian/wiringpi.install
./home/pi/wiringPi/debian/libwiringpi2.install
./home/pi/wiringPi/debian/libwiringpi-dev.install
./home/pi/wiringPi/debian/wiringpi.dirs
./home/pi/wiringPi/debian/libwiringpi-dev.dirs
./home/pi/wiringPi/debian-template/wiringPi
./home/pi/wiringPi/devLib/libwiringPiDev.so.2.46
./home/pi/wiringPi/wiringPi
./home/pi/wiringPi/wiringPi/wiringPiSPI.o
./home/pi/wiringPi/wiringPi/wiringShift.c
./home/pi/wiringPi/wiringPi/wiringPiSPI.h
./home/pi/wiringPi/wiringPi/wiringSerial.c
./home/pi/wiringPi/wiringPi/libwiringPi.so.2.46
./home/pi/wiringPi/wiringPi/wiringPi.c
./home/pi/wiringPi/wiringPi/wiringPiI2C.h
./home/pi/wiringPi/wiringPi/wiringSerial.h
./home/pi/wiringPi/wiringPi/wiringPiI2C.c
./home/pi/wiringPi/wiringPi/wiringPiSPI.c
./home/pi/wiringPi/wiringPi/wiringSerial.o
./home/pi/wiringPi/wiringPi/wiringShift.h
./home/pi/wiringPi/wiringPi/wiringPi.o
./home/pi/wiringPi/wiringPi/wiringPiI2C.o
./home/pi/wiringPi/wiringPi/wiringShift.o
./home/pi/wiringPi/wiringPi/wiringPi.h
./usr/local/lib/libwiringPiDev.so
./usr/local/lib/libwiringPi.so.2.46
./usr/local/lib/libwiringPi.so
./usr/local/lib/libwiringPiDev.so.2.46
./usr/local/include/wiringPiSPI.h
./usr/local/include/wiringPiI2C.h
./usr/local/include/wiringSerial.h
./usr/local/include/wiringShift.h
./usr/local/include/wiringPi.h
./usr/lib/libwiringPiDev.so
./usr/lib/libwiringPi.soThis is what I currently have in sysroot:
ri@PC:~/raspi2 $ sudo find -name wiri
./sysroot/usr/include/wiringPi.h
./sysroot/usr/include/wiringShift.h
./sysroot/usr/include/wiringPiI2C.h
./sysroot/usr/include/wiringSerial.h
./sysroot/usr/include/libwiringPi.so
./sysroot/usr/include/libwiringPiDev.so
./sysroot/usr/include/wiringPiSPI.h
./sysroot/usr/lib/libwiringPi.so
./sysroot/usr/lib/libwiringPiDev.soThis is what I have in .pro
TEMPLATE = app
CONFIG += console
///EDIT: Removed wrong tested compiler option
CONFIG -= app_bundle
CONFIG -= qtINCLUDEPATH += /home/ri/raspi2/sysroot/usr/lib/
INCLUDEPATH += /home/ri/raspi2/sysroot/usr/include/LIBS += -L"/home/ri/raspi2/sysroot/usr/include" -libwiringPi.so
LIBS += -L"/home/ri/raspi2/sysroot/usr/include" -libwiringPiDev.so
LIBS += -lwiringPi -lwiringPiDevHEADERS +=
wiringpi.hSOURCES +=
main.ctarget.path = /home/pi/wire
INSTALLS += targetThe compiler does not find the libraries except wirinpi.h and all files in RPi don't seem to be synced back to my host(but do they even need to be?) There probably are many things wrong but the first thing I would like to know is if the sysroot folder structure should somehow be revised to match what is in RPi for wiringpi and how.
EDIT: This the sysroot folder structure:
mkdir sysroot sysroot/usr sysroot/opt
I ran these again after I instlled wiringpi on RPi
rsync -avz pi@raspberrypi.local:/lib sysroot
rsync -avz pi@raspberrypi.local:/usr/include sysroot/usr
rsync -avz pi@raspberrypi.local:/usr/lib sysroot/usr
rsync -avz pi@raspberrypi.local:/opt/vc sysroot/optThanx
PS. If I get this to work I also need to be able to use RPi's serial interface to read analog data from an Arduino which should be connected via USB cable (serial). That probably needs some libraries too if not already in place.
-
In an old topic I found this interesting reply from @SGaist (post/381375):
snip ... install the development package on the RPi and sync the sysroot you use when cross-compiling your application ...
I got cross-compiling for RPi2 & RPi3 to work for Qt 5.10.1 using the guide in wiki.qt.io/RaspberryPi2EGLFS and have then been trying to get the wirinpi lib to function too. I have tried to sync the needed stuff back to the host from RPi using rsync but haven't got things to work. Can someone please clarify what to do for the sysroot folder (if anything) to get all the wiringpi libraries in proper places. This is a list of the wiringpi related stuff on RPi:
pi@rpi2:/ $ sudo find -name wiri
./home/pi/sysroot/usr/lib/libwiringPiDev.so
./home/pi/sysroot/usr/lib/libwiringPi.so
./home/pi/wiringPi
./home/pi/wiringPi/wiringPiD
./home/pi/wiringPi/wiringPiD/wiringpid.c
./home/pi/wiringPi/debian/libwiringpi2.shlibs
./home/pi/wiringPi/debian/wiringpi.install
./home/pi/wiringPi/debian/libwiringpi2.install
./home/pi/wiringPi/debian/libwiringpi-dev.install
./home/pi/wiringPi/debian/wiringpi.dirs
./home/pi/wiringPi/debian/libwiringpi-dev.dirs
./home/pi/wiringPi/debian-template/wiringPi
./home/pi/wiringPi/devLib/libwiringPiDev.so.2.46
./home/pi/wiringPi/wiringPi
./home/pi/wiringPi/wiringPi/wiringPiSPI.o
./home/pi/wiringPi/wiringPi/wiringShift.c
./home/pi/wiringPi/wiringPi/wiringPiSPI.h
./home/pi/wiringPi/wiringPi/wiringSerial.c
./home/pi/wiringPi/wiringPi/libwiringPi.so.2.46
./home/pi/wiringPi/wiringPi/wiringPi.c
./home/pi/wiringPi/wiringPi/wiringPiI2C.h
./home/pi/wiringPi/wiringPi/wiringSerial.h
./home/pi/wiringPi/wiringPi/wiringPiI2C.c
./home/pi/wiringPi/wiringPi/wiringPiSPI.c
./home/pi/wiringPi/wiringPi/wiringSerial.o
./home/pi/wiringPi/wiringPi/wiringShift.h
./home/pi/wiringPi/wiringPi/wiringPi.o
./home/pi/wiringPi/wiringPi/wiringPiI2C.o
./home/pi/wiringPi/wiringPi/wiringShift.o
./home/pi/wiringPi/wiringPi/wiringPi.h
./usr/local/lib/libwiringPiDev.so
./usr/local/lib/libwiringPi.so.2.46
./usr/local/lib/libwiringPi.so
./usr/local/lib/libwiringPiDev.so.2.46
./usr/local/include/wiringPiSPI.h
./usr/local/include/wiringPiI2C.h
./usr/local/include/wiringSerial.h
./usr/local/include/wiringShift.h
./usr/local/include/wiringPi.h
./usr/lib/libwiringPiDev.so
./usr/lib/libwiringPi.soThis is what I currently have in sysroot:
ri@PC:~/raspi2 $ sudo find -name wiri
./sysroot/usr/include/wiringPi.h
./sysroot/usr/include/wiringShift.h
./sysroot/usr/include/wiringPiI2C.h
./sysroot/usr/include/wiringSerial.h
./sysroot/usr/include/libwiringPi.so
./sysroot/usr/include/libwiringPiDev.so
./sysroot/usr/include/wiringPiSPI.h
./sysroot/usr/lib/libwiringPi.so
./sysroot/usr/lib/libwiringPiDev.soThis is what I have in .pro
TEMPLATE = app
CONFIG += console
///EDIT: Removed wrong tested compiler option
CONFIG -= app_bundle
CONFIG -= qtINCLUDEPATH += /home/ri/raspi2/sysroot/usr/lib/
INCLUDEPATH += /home/ri/raspi2/sysroot/usr/include/LIBS += -L"/home/ri/raspi2/sysroot/usr/include" -libwiringPi.so
LIBS += -L"/home/ri/raspi2/sysroot/usr/include" -libwiringPiDev.so
LIBS += -lwiringPi -lwiringPiDevHEADERS +=
wiringpi.hSOURCES +=
main.ctarget.path = /home/pi/wire
INSTALLS += targetThe compiler does not find the libraries except wirinpi.h and all files in RPi don't seem to be synced back to my host(but do they even need to be?) There probably are many things wrong but the first thing I would like to know is if the sysroot folder structure should somehow be revised to match what is in RPi for wiringpi and how.
EDIT: This the sysroot folder structure:
mkdir sysroot sysroot/usr sysroot/opt
I ran these again after I instlled wiringpi on RPi
rsync -avz pi@raspberrypi.local:/lib sysroot
rsync -avz pi@raspberrypi.local:/usr/include sysroot/usr
rsync -avz pi@raspberrypi.local:/usr/lib sysroot/usr
rsync -avz pi@raspberrypi.local:/opt/vc sysroot/optThanx
PS. If I get this to work I also need to be able to use RPi's serial interface to read analog data from an Arduino which should be connected via USB cable (serial). That probably needs some libraries too if not already in place.
@robopoulos couple of things I can see quickly:
- You have Wiring Pi installed in a bunch of different locations in your RPi device. I understand that you should have it installed under /usr/lib (.so) and /usr/include (.h) only. Those are the locations that you then sync
rsync -avz pi@raspberrypi.local:/usr/include sysroot/usr rsync -avz pi@raspberrypi.local:/usr/lib sysroot/usr
- You don't need both wiringPi and wiringPiDev shared libraries unless you're using the Gertboard, MaxDetect, etc. see here
NOTE: To compile programs with wiringPi, you need to add:
-lwiringPi
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
-lwiringPiDev
to your compile line(s).so this fragment from your .pro
INCLUDEPATH += /home/ri/raspi2/sysroot/usr/lib/ INCLUDEPATH += /home/ri/raspi2/sysroot/usr/include/ LIBS += -L"/home/ri/raspi2/sysroot/usr/include" -libwiringPi.so LIBS += -L"/home/ri/raspi2/sysroot/usr/include" -libwiringPiDev.so LIBS += -lwiringPi -lwiringPiDev
should change into:
INCLUDEPATH += /home/ri/raspi2/sysroot/usr/include/ LIBS += -L"/home/ri/raspi2/sysroot/usr/lib" LIBS += -lwiringPi
PS. If I get this to work I also need to be able to use RPi's serial interface
You may want to take a look at the simplified serial port handling library included in WiringPi.
-
Thanks! As seen from the listings the libs were already in the proper folders. Then after you fixed the .pro the -lwiringPi still wasn't found so I inspected the files with Filezilla on RPi and it revealed that the .so files synced to the host were just but links(!) pointing to the to the original wiringPi build folder. I copied the actual .so files from the original build file to the host and now it works!
THANX!
I mark this as solved. Perhaps I start a new topic if I need help for the serial Arduino connection.
-
Thanks! As seen from the listings the libs were already in the proper folders. Then after you fixed the .pro the -lwiringPi still wasn't found so I inspected the files with Filezilla on RPi and it revealed that the .so files synced to the host were just but links(!) pointing to the to the original wiringPi build folder. I copied the actual .so files from the original build file to the host and now it works!
THANX!
I mark this as solved. Perhaps I start a new topic if I need help for the serial Arduino connection.
@robopoulos said in How to set up RPi WiringPi library and other libs for Qt cross-compile:
Glad you solved your issue.
Perhaps I start a new topic if I need help for the serial Arduino connection.
Yes please. Keep the forum tidy, one subject per post so other users can find help easier
-
@Pablo J. Rogina I was setting up my ubuntu for cross compilation when including the wiringPi.h header file in the .pro file like this
INCLUDEPATH += /usr/local/include
LIBS += -L"/usr/local/lib" -lwiringpi
i got an error
can you please help me out
-
@Pablo J. Rogina I was setting up my ubuntu for cross compilation when including the wiringPi.h header file in the .pro file like this
INCLUDEPATH += /usr/local/include
LIBS += -L"/usr/local/lib" -lwiringpi
i got an error
can you please help me out
@barath-19-2 Did you install the lib in /usr/local/lib? Is the lib there?
Also, what is the exact file name of the lib?
And it looks like you're not doing cross-compalation? -
@barath-19-2 Did you install the lib in /usr/local/lib? Is the lib there?
Also, what is the exact file name of the lib?
And it looks like you're not doing cross-compalation?@jsulm
here is a screen-shot of the directory
and this is the header file i downloaded from the unofficial git hub mirror because official was unavailable
after doing ./build i did same told in the previous conversations of this topic to do it the header file got included the header files and functions come in auto-complete when codding but this error pops up while building
-
@barath-19-2 Did you install the lib in /usr/local/lib? Is the lib there?
Also, what is the exact file name of the lib?
And it looks like you're not doing cross-compalation?@jsulm I used flash boot to QT Device to flash my SD card for Raspberry Pi to upload their Boot to Qt into SD card as showed in qthelp://io.qt.b2qt.598/b2qt/qtee-preparing-hardware-rasberrypi.html#2-installing-boot-to-qt-software-stack after this I thought i could cross-compile but when ran the example in it. It ran with no errors
-
@jsulm I used flash boot to QT Device to flash my SD card for Raspberry Pi to upload their Boot to Qt into SD card as showed in qthelp://io.qt.b2qt.598/b2qt/qtee-preparing-hardware-rasberrypi.html#2-installing-boot-to-qt-software-stack after this I thought i could cross-compile but when ran the example in it. It ran with no errors
@barath-19-2 It's apparently wiringPi not wiringpi...
-
@jsulm tnx it is now saying file format is not recognized
-
@jsulm tnx it is now saying file format is not recognized
@barath-19-2 I asked before: "And it looks like you're not doing cross-compalation?"
So, are you doing cross-compilation?
The wiringPi library is apparently not compatible with your platform.
If you build on your PC/Laptop for Raspberry Pi you have to do cross compilation as Raspberry Pi is ARM and not x86.
So, did you set up a cross compilation environment?