Solved WiringPi build error
-
I am developing a cross compile of raspberrypi from ubuntu linux pc.
I want to use wiringPi to control gpio.
I installed wiringPi on raspberrypi.
I entered the following in .pro for ubuntu's qt project:
#LIBS + = -L / usr / local / lib / -lwiringPi
However, the following error occurred,
'File not recognized: File format not recognized (/usr/local/lib/libwiringPi.so)I have verified that there is a libwringPi.so file in the / usr / local / lib path of raspberrypi.
What should I do?
-
@this What does (executed in a terminal)
file /usr/local/lib/libwiringPi.so
say?
It looks like you're mixing different architectures (ARM and x86). For cross compilation you need to use ARM version of this lib as you're building for ARM. -
@jsulm Do you mean to add a phrase to your .pro file?
#LIBS + = -L / usr / local / lib /libwiringPi.soI've tried it, but I get the same error.
-
@this No, that's not what I mean.
What I mean: you need to use ARM build of libwiringPi for RPi.
Can you please try what I asked before?
What does (executed in a terminal)file /usr/local/lib/libwiringPi.so
say?
This line is wrong in many ways:
#LIBS + = -L / usr / local / lib /libwiringPi.so
First: it is commented out. Second: the path contains spaces. Third: you're using LIBS wrongly, it must be:
LIBS+=-L/usr/local/lib -lwiringPi
-
@jsulm Sorry, but I did not understand.
Do you want to type "file /usr/local/lib/libwiringPi.so" in the terminal?I entered the following results
/usr/local/lib/libwiringPi.so:symbolic link to libwiringPi.so.2.44
-
-
@jsulm I entered 'file /usr/local/lib/libwiringPi.so.2.44' in the terminal.
I got the following results./usr/local/lib/libwiringPi.so.2.44: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID [sha1] = 13145f24d2081640dbda7cfb4d9648ceea0a77d6, not stripped
I modified the LIBS as you said.
But there are still errors. -
@this Which errors?
-
@jsulm It is the same error as the first inquiry.
"file not recognized:file format not recognized
/usr/local/lib/libwiringPi.so
collect2:error:ld returned 1 exit status" -
@this Did you rerun qmake after fixing LIBS in pro file?
-
@jsulm Yes, of course.
I also run rebuild.
However, the same error occurs. -
@this Can you show your pro file and the build log? Are you actually building for ARM?
-
@jsulm ![alt text](image url)
Do you need more information?
-
@this Yes, I need the build log ("Compile Output" tab in QtCreator)
-
@jsulm ![alt text](image url)
I am cross compiling Linux (ubuntu) to raspberrypi.
-
@this The lib is EABI5: "ELF 32-bit LSB shared object, ARM, EABI5". I think RPi uses EABI7 or something. From where did you get the lib?
-
@jsulm I'm sorry, but I do not know what lib is.
I can not understand your words.
Are you referring to qt lib?
Are you talking raspberrypi?We have installed cross compile environment by referring to the following site.
https://medium.com/@amirmann/how-to-cross-compile-qt-for-raspberry-pi-3-on-linux-ubuntu-for-beginners-75acf2a078c -
@this I'm talking about libwiringPi.so
How did you install this lib? Was it part of this cross compiling environment or did you get it from somewhere else? -
@jsulm I am sorry.
Installed.
The installation process is as follows:git clone git://git.drogon.net/wiringPi
cd wiringPi/
git pull origin
./buildAt first we installed wiringPi from ubuntu pc.
However, I got the error like above and installed raspberrypi in the same way. -
@this Sorry can you explain this: "At first we installed wiringPi from ubuntu pc.
However, I got the error like above and installed raspberrypi in the same way."Do you mean you built it on the RaspberryPi and copied then to your Ubuntu PC?
You should build it on your Ubuntu machine, but use the cross compilation environment.