Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.
How to set up RPi WiringPi library and other libs for Qt cross-compile
robopoulos last edited by robopoulos
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
This is what I currently have in sysroot:
ri@PC:~/raspi2 $ sudo find -name wiri
This is what I have in .pro
TEMPLATE = app
CONFIG += console
///EDIT: Removed wrong tested compiler option
CONFIG -= app_bundle
CONFIG -= qt
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
target.path = /home/pi/wire
INSTALLS += target
The 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 firstname.lastname@example.org:/lib sysroot
rsync -avz email@example.com:/usr/include sysroot/usr
rsync -avz firstname.lastname@example.org:/usr/lib sysroot/usr
rsync -avz email@example.com:/opt/vc sysroot/opt
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.
Pablo J. Rogina last edited by
@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 firstname.lastname@example.org:/usr/include sysroot/usr rsync -avz email@example.com:/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:
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
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.
robopoulos last edited by
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!
I mark this as solved. Perhaps I start a new topic if I need help for the serial Arduino connection.
Pablo J. Rogina last edited by
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
@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?
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
@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
@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?