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