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?


  • Moderators

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

    I've tried it, but I get the same error.


  • Moderators

    @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


  • Moderators

    @this Now do

    file /usr/local/lib/libwiringPi.so.2.44
    

    And please fix LIBS as I said.



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


  • Moderators

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


  • Moderators

    @this Did you rerun qmake after fixing LIBS in pro file?



  • @jsulm Yes, of course.
    I also run rebuild.
    However, the same error occurs.


  • Moderators

    @this Can you show your pro file and the build log? Are you actually building for ARM?



  • @jsulm ![alt text](image url)0_1500020449778_capture2017-07-14 17-15-11.png

    Do you need more information?


  • Moderators

    @this Yes, I need the build log ("Compile Output" tab in QtCreator)



  • @jsulm ![alt text](image url)0_1500020738334_capture, 2017-07-14 17-24-01.png

    I am cross compiling Linux (ubuntu) to raspberrypi.


  • Moderators

    @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


  • Moderators

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

    At first we installed wiringPi from ubuntu pc.
    However, I got the error like above and installed raspberrypi in the same way.


  • Moderators

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



  • @jsulm Well ... you seem to have misunderstood.
    The build is ubuntu -> raspberrypi. (Cross compile)

    I have been struggling to eliminate the errors that have occurred.

    I first installed wiringPi via the terminal from ubuntu pc.

    However, I thought that a file not recognized error occurred and there was no file in raspberrypi.

    So raspberrypi installed wiringPi through the terminal.
    So I installed wiringPi related files in raspberrypi's / usr / local / lib folder.

    I thought this was the cause of the error.

    However, as you know, the error was not resolved and the question was raised


  • Moderators

    @this I know that you're cross compiling.
    "However, I thought that a file not recognized error occurred and there was no file in raspberrypi." - for cross compilation it doesn't matter whether the lib is on RaspberryPi or not as you're building on your Ubuntu machine - you need it on your Ubuntu machine.
    So, on your Ubuntu machine the lib is this: /usr/local/lib/libwiringPi.so (symbolic link) and /usr/local/lib/libwiringPi.so.2.44 (lib itself), right?



  • This post is deleted!


  • @jsulm I solved the above error.
    LIBS += -L/usr/local/lib-lwiringPi
    I made a mistake in the spacing.
    However, a new error has occurred.
    Is this what I am doing wrong?
    I wrote the following in .pro.
    INCLUDEPATH + = / usr / local / include
    LIBS += -L/usr/local/lib-lwiringPi

    ![alt text](0_1500250620685_스크린샷, 2017-07-17 09-16-38.png image url)

    ![alt text](0_1500250727583_스크린샷, 2017-07-17 08-44-26.png image url)



  • @this I got the above error and I deleted wiringPi and reinstalled it.
    However, the following error occurs during installation.

    Is this the problem that caused this error?

    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    root@smart-HP-Z400-Workstation:~/wiringPi# ./build
    wiringPi Build script

    WiringPi Library
    [UnInstall]
    [Compile] wiringPi.c
    [Compile] wiringSerial.c
    [Compile] piHiPri.c
    [Compile] wiringShift.c
    [Compile] piThread.c
    wiringSerial.c: In function ‘serialPutchar’:
    wiringSerial.c:158:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write (fd, &c, 1) ;
    ^
    wiringSerial.c: In function ‘serialPuts’:
    wiringSerial.c:170:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write (fd, s, strlen (s)) ;
    ^
    [Compile] softPwm.c
    [Compile] wiringPiSPI.c
    [Compile] wiringPiI2C.c
    [Compile] softTone.c
    wiringPi.c:1247:21: warning: ‘digitalRead8Dummy’ defined but not used [-Wunused-function]
    static unsigned int digitalRead8Dummy (UNU struct wiringPiNodeStruct *no
    ^
    wiringPi.c:1248:21: warning: ‘digitalWrite8Dummy’ defined but not used [-Wunused-function]
    static void digitalWrite8Dummy (UNU struct wiringPiNodeStruct *no
    ^
    wiringPi.c: In function ‘digitalRead’:
    [Compile] mcp23008.c
    wiringPi.c:1473:7: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
    read (sysFds [pin], &c, 1) ;
    ^
    wiringPi.c: In function ‘digitalWrite’:
    wiringPi.c:1535:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write (sysFds [pin], "0\n", 2) ;
    ^
    wiringPi.c:1537:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write (sysFds [pin], "1\n", 2) ;
    ^
    wiringPi.c: In function ‘waitForInterrupt’:
    wiringPi.c:1837:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
    (void)read (fd, &c, 1) ; // Read & clear
    ^
    wiringPi.c: In function ‘wiringPiISR’:
    wiringPi.c:1953:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
    read (sysFds [bcmGpioPin], &c, 1) ;
    ^
    [Compile] mcp23016.c
    [Compile] mcp23017.c
    [Compile] mcp23s08.c
    [Compile] mcp23s17.c
    [Compile] sr595.c
    [Compile] pcf8574.c
    [Compile] pcf8591.c
    [Compile] mcp3004.c
    [Compile] mcp4802.c
    [Compile] mcp3002.c
    pcf8591.c: In function ‘myAnalogWrite’:
    pcf8591.c:44:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write (node->fd, b, 2) ;
    ^
    [Compile] max31855.c
    [Compile] mcp3422.c
    [Compile] max5322.c
    mcp3422.c: In function ‘waitForConversion’:
    mcp3422.c:50:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
    read (fd, buffer, n) ;
    ^
    [Compile] ads1115.c
    [Compile] sn3218.c
    [Compile] bmp180.c
    [Compile] htu21d.c
    [Compile] ds18b20.c
    [Compile] rht03.c
    [Compile] drcSerial.c
    [Compile] drcNet.c
    [Compile] pseudoPins.c
    [Compile] wpiExtensions.c
    pseudoPins.c: In function ‘myAnalogRead’:
    pseudoPins.c:50:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    int *ptr = (int *)node->data0 ;
    ^
    pseudoPins.c: In function ‘myAnalogWrite’:
    pseudoPins.c:59:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    int *ptr = (int *)node->data0 ;
    ^
    pseudoPins.c: In function ‘pseudoPinsSetup’:
    pseudoPins.c:89:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    node->data0 = (unsigned int)ptr ;
    ^
    [Link (Dynamic)]
    [Install Headers]
    [Install Dynamic Lib]

    WiringPi Devices Library
    [UnInstall]
    [Compile] ds1302.c
    [Compile] maxdetect.c
    [Compile] gertboard.c
    [Compile] piFace.c
    [Compile] piNes.c
    [Compile] lcd.c
    [Compile] lcd128x64.c
    [Compile] scrollPhat.c
    [Compile] piGlow.c
    [Link (Dynamic)]
    [Install Headers]
    [Install Dynamic Lib]

    GPIO Utility
    [Compile] gpio.c
    [Compile] readall.c
    [Compile] pins.c
    gpio.c: In function ‘doVersion’:
    gpio.c:1292:7: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
    fgets (name, 80, fd) ;
    ^
    gpio.c: In function ‘doLoad’:
    gpio.c:285:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
    system (cmd) ;
    ^
    gpio.c:291:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
    system (cmd) ;
    ^
    gpio.c: In function ‘doUnLoad’:
    gpio.c:345:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
    system (cmd) ;
    ^
    gpio.c:351:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
    system (cmd) ;
    ^
    [Link]
    [Install]

    All Done.

    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).
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



  • @this I changed the version of qt and run it without errors.
    The version I used was qt5.4.2.
    I changed it to another version and it builds without errors.
    Thank you for your help.

    Is there a problem with qt5.4.2?
    Hangul (Korean language) was also out of print, I had to worry about changing the version.
    But wiringPi is also incompatible
    Is there a problem with qt5.4.2 version?


  • Moderators

    @this wiringPi isn't a Qt library to my knowledge, so it is not a Qt problem.
    This is wrong:

    LIBS += -L/usr/local/lib-lwiringPi
    

    it must be:

    LIBS += -L/usr/local/lib -lwiringPi
    

    (space between lib and -l).
    I really don't know what you are doing wrong. You should read http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
    Also, "undefined reference" errors means that the a library (in your case wiringPi) is missing. Take a closer look at the compiler/linker output.
    You can try to write a simple C++ console application without Qt but with wiringPi. Just create a makefile and build your app.



  • @jsulm Qt Build with no error when running with version 5.5.1.
    However, when building with qt 4.5.2, the above error also occurs.
    Is not this a version issue?
    Space above the space is filled in.
    I misplaced that article.


  • Moderators

    @this Again: wiringPi is not a Qt library. In fact it is not even C++, it is a C library. You don't build it with Qt (Qt is not a compiler) you build it with a C compiler (gcc).
    So what is the problem now: you can't build wiringPi or you can't build your Qt app which uses this lib?



  • @jsulm I am developing in qt.
    So I need to build wiringPi using qt.

    I think I can use wiringPi in qt.
    WiringPi is a c language library.
    So is it impossible to use in qt?
    If I can not use wiringPi in qt, I will code it in another way for GPIO control.

    If available in qt,
    Having said that,
    Ubuntu pc -> raspberrypi (rasbian)
    I am developing using cross compile.
    I am developing using qt 5.4.2.

    I tried to continue but failed to recognize the wiringPi function.

    So I tried qt 5.5.1.
    Qt 5.5.1 is not a cross compile.
    I run it on qt of ubuntu pc.

    The same source and the same project.
    Changed version and os of qt.
    (Note that changing os does not mean that raspberrypi has built the program.
    It refers to the os where the qt file is executed.)
    It recognizes wiringPi without error.

    So I think.
    Whether wiringPi is compatible with the Qt version,
    Whether wirignPi is not available depending on OS

    Do you understand my situation now?


  • Moderators

    @this said in WiringPi build error:

    So I need to build wiringPi using qt.

    You don't build it using Qt, Qt is not a compiler. You need to understand the difference: Qt is just a C++ framework. You build the library using a compiler, not Qt.

    Yes, you can use C libraries in C++ projects. So, you can use it in your Qt project.

    "Whether wiringPi is compatible with the Qt version" - this does not make sense as wiringPi and Qt are two completely independent things, there is no compatibility. Your problem is not compatibility with Qt, your problem is with the wiringPi library which is apparently not compatible with the ABI you're using as the linker error clearly states. You most probably built wiringPi with a different compiler with different parameters. See one of my posts above: "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?" - this does not have anything to do with Qt.

    We already discuss this for long time now. I asked you whether you built wiringPi on your RaspberyPi and then copied the lib to your PC? Did you? You should build wiringPi with exact same compiler you're using for cross compilation (means: you need to cross compile wiringPi).
    So, my question is: how exactly did you build wiringPi for RaspberryPi?



  • @jsulm So, do you use wiringPI installed from raspberrypi?
    Do you want to copy the wiringPi installed by raspberrypi and enter the link to the ubuntu pc?

    I did not build wiringPi for cross compilation.
    I kept asking the way.

    What should I set up to use wiringPI in a cross-compilation environment?

    I do not speak English well.
    We still communicate using translator.
    Please describe in simple words.


  • Moderators



  • @jsulm I do not understand how to use wiringPi in a cross compile.

    Is wiringPi installed on raspberrypi?
    Is the link path of the LIBS a wiringPi location in raspberrypi?
    Is not wiringPi down to ubuntu-> rasberrpy when cross compile?
    I wonder how the wiringPi library is cross compiled.

    If wiringPi should be present in rasberrypi,
    Can I import files located in rasberrypi on a ubuntu pc into LIBS?

    I am running the qt project on ubuntu, is it that the library at a specific location in rasberrpypi is loaded and executed before the build?

    I can not understand.
    I do not understand the relationship of linking wiringPI to LIBS.

    Where does wringPI go to as a cross compile?


  • Moderators

    @this Usually, if you cross compile you have a sysroot. A sysroot is the file system of your target device containing all needed header files and libraries. That means: the path you use for wiringPi would usually be the one pointing to your sysroot. It looks like you have your sysroot under /mnt/rasp-pi-rootfs.
    Try (I assume you have wiringPi under /usr/local/lib on your RaspberryPi, correct the path if it is different):

    -L/mnt/rasp-pi-rootfs/usr/local/lib -lwiringPi
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.