Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Linker error

Linker error

Scheduled Pinned Locked Moved C / C++ / MFC
helphardwarequestionlinux
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Vaclav_

    I am compiling C code for embedded application using TCF. My "debug" compile is on x86 and works fine My "release" on ARM (raspberry Pi ) compiles but won't link on ARM platform with identical compiler "Settings" options. GCC on x86 - command “gcc” with #include #include "/usr/local/include/wiringPiSPI.h" It compiles and link and run the code on x86 platform. -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O0 -g3 -Wall -c -fmessage-length=020:23:17 **** Results of build Incremental Build of configuration Debug for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Finished building: ../src/ESA_SPI.c Building target: ESA_SPI Invoking: Cross GCC Linker gcc -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthread -lm -lcrypt Finished building target: ESA_SPI 20:23:18 Build Finished (took 288ms) Here are the options and compiler / linker outputs on ARM platform. GCC on ARM with command arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -Wall -c -fmessage-length=0 20:29:57 Build Finished (took 127ms) 20:29:57 **** Incremental Build of configuration Release for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Finished building: ../src/ESA_SPI.c Building target: ESA_SPI Invoking: Cross GCC Linker arm-linux-gnueabihf-gcc -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthead -lm -lcrypt /usr/lib/../lib/libwiringPi.so: file not recognized: File format not recognized collect2: error: ld returned 1 exit status make: *** [ESA_SPI] Error 1 20:29:57 Build Finished (took 280ms) My question is - where does the "libwiringPi.so" error come from? What needs to be optioned differently for the ARM compiler or do I have to modify something else? Any help would be appreciated to resolve / give me a hit how to fix this. Cheers Vaclav

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #3

    As Richard stated, the library must be cross-compiled for ARM is order to be correctly linked to your application (please note, the build instructions on WiringPi website[^] assume you are building it on the actual raspberry PI.).

    In testa che avete, signor di Ceprano?

    V 1 Reply Last reply
    0
    • CPalliniC CPallini

      As Richard stated, the library must be cross-compiled for ARM is order to be correctly linked to your application (please note, the build instructions on WiringPi website[^] assume you are building it on the actual raspberry PI.).

      V Offline
      V Offline
      Vaclav_
      wrote on last edited by
      #4

      Yes, I did follow this instruction on both x86 and ARM To build/install there is a new simplified script: $ cd ~/wiringPi $ ./build The new build script will compile and install it all for you – it does use the sudo command at one point, so you may wish to inspect the script before running it. I just do not get where the "lib" prefix came from. I am still not too comfortable with Linux files scheme so I may be "linked" to wrong place. I need to study "make" to get better idea how compiler does "build" and where all those "includes" come from. For example how does "include /usr/local/include " translates to "/home/pi/wiringPi/wiringPi"? Or does it ? Stand by , I'll come back after I take a closer look at compiler and make. Thanks for your help. Vaclav FYI here is what is in directory and apparently the *.h file in question is "included" but I see only "libwiringPi.so.2.44" file. root@pi:/home/pi/wiringPi/wiringPi# ls ads1115.c max31855.c mcp23s17.o piHiPri.c sr595.c ads1115.h max31855.h mcp23x0817.h piHiPri.o sr595.h ads1115.o max31855.o mcp23x08.h piThread.c sr595.o bmp180.c max5322.c mcp3002.c piThread.o wiringPi.c bmp180.h max5322.h mcp3002.h pseudoPins.c wiringPi.h bmp180.o max5322.o mcp3002.o pseudoPins.h wiringPiI2C.c COPYING.LESSER mcp23008.c mcp3004.c pseudoPins.o wiringPiI2C.h drcNet.c mcp23008.h mcp3004.h rht03.c wiringPiI2C.o drcNet.h mcp23008.o mcp3004.o rht03.h wiringPi.o drcNet.o mcp23016.c mcp3422.c rht03.o wiringPiSPI.c drcSerial.c mcp23016.h mcp3422.h sn3218.c wiringPiSPI.h drcSerial.h mcp23016.o mcp3422.o sn3218.h wiringPiSPI.o drcSerial.o mcp23016reg.h mcp4802.c sn3218.o wiringSerial.c ds18b20.c mcp23017.c mcp4802.h softPwm.c wiringSerial.h ds18b20.h mcp23017.h mcp4802.o softPwm.h wiringSerial.o ds18b20.o mcp23017.o pcf8574.c softPwm.o wiringShift.c htu21d.c mcp23s08.c pcf8574.h softServo.c wiringShift.h htu21d.h mcp23s08.h pcf8574.o softServo.h wiringShift.o htu21d.o mcp23s08.o pcf8591.c softTone.c wpiExtensions.c libwiringPi.so.2.44 mcp23s17.c pcf8591.h softTone.h wpiExtensions.h Makefile mcp23s17.h pcf8591.o softTone.o wpiExtensions.o root@pi:/home/pi/wiringPi/wiringPi#

      L 1 Reply Last reply
      0
      • V Vaclav_

        Yes, I did follow this instruction on both x86 and ARM To build/install there is a new simplified script: $ cd ~/wiringPi $ ./build The new build script will compile and install it all for you – it does use the sudo command at one point, so you may wish to inspect the script before running it. I just do not get where the "lib" prefix came from. I am still not too comfortable with Linux files scheme so I may be "linked" to wrong place. I need to study "make" to get better idea how compiler does "build" and where all those "includes" come from. For example how does "include /usr/local/include " translates to "/home/pi/wiringPi/wiringPi"? Or does it ? Stand by , I'll come back after I take a closer look at compiler and make. Thanks for your help. Vaclav FYI here is what is in directory and apparently the *.h file in question is "included" but I see only "libwiringPi.so.2.44" file. root@pi:/home/pi/wiringPi/wiringPi# ls ads1115.c max31855.c mcp23s17.o piHiPri.c sr595.c ads1115.h max31855.h mcp23x0817.h piHiPri.o sr595.h ads1115.o max31855.o mcp23x08.h piThread.c sr595.o bmp180.c max5322.c mcp3002.c piThread.o wiringPi.c bmp180.h max5322.h mcp3002.h pseudoPins.c wiringPi.h bmp180.o max5322.o mcp3002.o pseudoPins.h wiringPiI2C.c COPYING.LESSER mcp23008.c mcp3004.c pseudoPins.o wiringPiI2C.h drcNet.c mcp23008.h mcp3004.h rht03.c wiringPiI2C.o drcNet.h mcp23008.o mcp3004.o rht03.h wiringPi.o drcNet.o mcp23016.c mcp3422.c rht03.o wiringPiSPI.c drcSerial.c mcp23016.h mcp3422.h sn3218.c wiringPiSPI.h drcSerial.h mcp23016.o mcp3422.o sn3218.h wiringPiSPI.o drcSerial.o mcp23016reg.h mcp4802.c sn3218.o wiringSerial.c ds18b20.c mcp23017.c mcp4802.h softPwm.c wiringSerial.h ds18b20.h mcp23017.h mcp4802.o softPwm.h wiringSerial.o ds18b20.o mcp23017.o pcf8574.c softPwm.o wiringShift.c htu21d.c mcp23s08.c pcf8574.h softServo.c wiringShift.h htu21d.h mcp23s08.h pcf8574.o softServo.h wiringShift.o htu21d.o mcp23s08.o pcf8591.c softTone.c wpiExtensions.c libwiringPi.so.2.44 mcp23s17.c pcf8591.h softTone.h wpiExtensions.h Makefile mcp23s17.h pcf8591.o softTone.o wpiExtensions.o root@pi:/home/pi/wiringPi/wiringPi#

        L Offline
        L Offline
        leon de boer
        wrote on last edited by
        #5

        Using the GNU Compiler Collection (GCC): Link Options[^] >>>>>> The only difference between using an -l option and specifying a file name is that -l surrounds library with ‘lib’ and ‘.a’ and searches several directories.

        In vino veritas

        J 1 Reply Last reply
        0
        • V Vaclav_

          I am compiling C code for embedded application using TCF. My "debug" compile is on x86 and works fine My "release" on ARM (raspberry Pi ) compiles but won't link on ARM platform with identical compiler "Settings" options. GCC on x86 - command “gcc” with #include #include "/usr/local/include/wiringPiSPI.h" It compiles and link and run the code on x86 platform. -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O0 -g3 -Wall -c -fmessage-length=020:23:17 **** Results of build Incremental Build of configuration Debug for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Finished building: ../src/ESA_SPI.c Building target: ESA_SPI Invoking: Cross GCC Linker gcc -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthread -lm -lcrypt Finished building target: ESA_SPI 20:23:18 Build Finished (took 288ms) Here are the options and compiler / linker outputs on ARM platform. GCC on ARM with command arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -Wall -c -fmessage-length=0 20:29:57 Build Finished (took 127ms) 20:29:57 **** Incremental Build of configuration Release for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Finished building: ../src/ESA_SPI.c Building target: ESA_SPI Invoking: Cross GCC Linker arm-linux-gnueabihf-gcc -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthead -lm -lcrypt /usr/lib/../lib/libwiringPi.so: file not recognized: File format not recognized collect2: error: ld returned 1 exit status make: *** [ESA_SPI] Error 1 20:29:57 Build Finished (took 280ms) My question is - where does the "libwiringPi.so" error come from? What needs to be optioned differently for the ARM compiler or do I have to modify something else? Any help would be appreciated to resolve / give me a hit how to fix this. Cheers Vaclav

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #6

          Your compiler command lines looks a little bit weird regarding the double quotes (especially the first group with the trailing -I):

          arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c"

          When there are no spaces in the arguments, the quotes can be omitted:

          arm-linux-gnueabihf-gcc -I/usr/local/include -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c"

          Note also that it is not necessary to specify library pathes and libraries when compiling only (option -c). These have to specified when linking (see below).

          /usr/lib/../lib/libwiringPi.so: file not recognized: File format not recognized

          You are linking with the shared library /usr/lib/libwiringPi.so. As far as I remember, the default WiringPi build will install the library into /usr/local/lib/. Check where the file in /usr/lib comes from and try to build after deleting (or renaming/moving) it. But before doing so fix your linker command line:

          arm-linux-gnueabihf-gcc -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthead -lm -lcrypt

          That is missing the additional library path and has a wrong pthread name (which does not care because GCC will detect the use of pthreads and link the library automatically so that it can be omitted):

          arm-linux-gnueabihf-gcc -L/usr/local/lib -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthread -lm -lcrypt

          Regarding the names libwiringPi.so and the linker command line option -lwiringPi: With Linux, all library files names should begin with lib and have the extension .so (or .a for static libraries). You can optionally (but it is usual) pass the short name (without prefix and extension) to the GCC linker command line.

          V 1 Reply Last reply
          0
          • L leon de boer

            Using the GNU Compiler Collection (GCC): Link Options[^] >>>>>> The only difference between using an -l option and specifying a file name is that -l surrounds library with ‘lib’ and ‘.a’ and searches several directories.

            In vino veritas

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #7

            ...that brings back memories (of trying to figure exactly that out.)

            1 Reply Last reply
            0
            • J Jochen Arndt

              Your compiler command lines looks a little bit weird regarding the double quotes (especially the first group with the trailing -I):

              arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c"

              When there are no spaces in the arguments, the quotes can be omitted:

              arm-linux-gnueabihf-gcc -I/usr/local/include -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c"

              Note also that it is not necessary to specify library pathes and libraries when compiling only (option -c). These have to specified when linking (see below).

              /usr/lib/../lib/libwiringPi.so: file not recognized: File format not recognized

              You are linking with the shared library /usr/lib/libwiringPi.so. As far as I remember, the default WiringPi build will install the library into /usr/local/lib/. Check where the file in /usr/lib comes from and try to build after deleting (or renaming/moving) it. But before doing so fix your linker command line:

              arm-linux-gnueabihf-gcc -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthead -lm -lcrypt

              That is missing the additional library path and has a wrong pthread name (which does not care because GCC will detect the use of pthreads and link the library automatically so that it can be omitted):

              arm-linux-gnueabihf-gcc -L/usr/local/lib -o "ESA_SPI" ./src/ESA_SPI.o -lwiringPi -lrt -lpthread -lm -lcrypt

              Regarding the names libwiringPi.so and the linker command line option -lwiringPi: With Linux, all library files names should begin with lib and have the extension .so (or .a for static libraries). You can optionally (but it is usual) pass the short name (without prefix and extension) to the GCC linker command line.

              V Offline
              V Offline
              Vaclav_
              wrote on last edited by
              #8

              Thanks for all the replies. I did some research and I am convinced that the missing library is in different directory. Makes no sense since the wiringPi was made for ARM / Raspberry PI and that is where the problem is. I have added verbose option and this is what I get now 3:41:22 **** Build of configuration Release for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -v -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Using built-in specs. COLLECT_GCC=arm-linux-gnueabihf-gcc Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabihf/include/c++/4.8.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-armhf-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include Thread model: posix gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) COLLECT_GCC_OPTIONS='-I' '-I/usr/local/include -L/usr/local/lib -lwiringPi' '-O3' '-v' '-Wall' '-c' '-fmessage-length=0' '-MMD' '-MP' '-MF' 'src/ESA_SPI.d' '-MT' 'src/ESA_SPI.o' '-o' 'src/ESA_SPI.o' '-march=armv7-a' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu' /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/cc1 -quiet -v -I -I/usr/loca

              J L 2 Replies Last reply
              0
              • V Vaclav_

                Thanks for all the replies. I did some research and I am convinced that the missing library is in different directory. Makes no sense since the wiringPi was made for ARM / Raspberry PI and that is where the problem is. I have added verbose option and this is what I get now 3:41:22 **** Build of configuration Release for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -v -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Using built-in specs. COLLECT_GCC=arm-linux-gnueabihf-gcc Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabihf/include/c++/4.8.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-armhf-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include Thread model: posix gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) COLLECT_GCC_OPTIONS='-I' '-I/usr/local/include -L/usr/local/lib -lwiringPi' '-O3' '-v' '-Wall' '-c' '-fmessage-length=0' '-MMD' '-MP' '-MF' 'src/ESA_SPI.d' '-MT' 'src/ESA_SPI.o' '-o' 'src/ESA_SPI.o' '-march=armv7-a' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu' /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/cc1 -quiet -v -I -I/usr/loca

                J Offline
                J Offline
                Jochen Arndt
                wrote on last edited by
                #9

                You have build wiringPi on the Pi using the build script. That will install the libraries to /usr/local/lib. Just have a look what is getting installed:

                joe@raspi-cross:~/raspi/sysroot/usr/local/lib$ ls -l libw*
                lrwxrwxrwx 1 joe joe 22 Jan 20 2016 libwiringPiDev.so -> libwiringPiDev.so.2.31
                -rwxr-xr-x 1 joe joe 23232 Jan 20 2016 libwiringPiDev.so.2.31
                lrwxrwxrwx 1 joe joe 19 Jan 20 2016 libwiringPi.so -> libwiringPi.so.2.31
                -rwxr-xr-x 1 joe joe 55808 Jan 20 2016 libwiringPi.so.2.31

                There are two shared libraries with the version as part of the name and two links that point to those. That is common with Linux. You can have different versions of a library which can be accessed using the full name and links pointing to a specific version (usually the most recent or the only version). This link name can be used instead (and then be shortened to be passed to the linker). So you can use in your case either -llibwiringPi.so.244 or -lwiringPi. Once installed, you can build your program on the Pi and link it with the library. But when using cross compilation, you have to make the libraries build on the Pi available to the cross setup. That can be done by copying the files or mounting the Pi file system (or parts of it) on the cross build system. The mounting can be done live (using network shares like NFS), using an image (e.g. by removing the SD card from the Pi and mounting it on the cross system), or some sync mechanism (which requires again network shares during synchronisation). In all cases you have to setup your cross system properly to use the mounted / copied files instead those of the host system itself (and use the cross tools instead of those from the host system). You may also build wiringPi on the cross system. But then you have to use the cross tools and specify the install directory to be the mounted Pi system instead of the host system. But the Pi system has to be mounted anyway to link with all the ARM libraries instead of the x86 libraries of the host system. As you can see from the above listing, I have mounted my Pi system at /home/joe/raspi/sysroot so that the cross build tools have access to all Pi files. I don't know how you have setup your cross compilation system. But you must set the include and library paths to those on the mounted Pi root system using environment variables, specify them in the make scripts, or pass them on the GCC command line.

                1 Reply Last reply
                0
                • V Vaclav_

                  Thanks for all the replies. I did some research and I am convinced that the missing library is in different directory. Makes no sense since the wiringPi was made for ARM / Raspberry PI and that is where the problem is. I have added verbose option and this is what I get now 3:41:22 **** Build of configuration Release for project ESA_SPI **** make all Building file: ../src/ESA_SPI.c Invoking: Cross GCC Compiler arm-linux-gnueabihf-gcc -I"-I/usr/local/include -L/usr/local/lib -lwiringPi" -O3 -v -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ESA_SPI.d" -MT"src/ESA_SPI.o" -o "src/ESA_SPI.o" "../src/ESA_SPI.c" Using built-in specs. COLLECT_GCC=arm-linux-gnueabihf-gcc Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabihf/include/c++/4.8.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-armhf-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include Thread model: posix gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) COLLECT_GCC_OPTIONS='-I' '-I/usr/local/include -L/usr/local/lib -lwiringPi' '-O3' '-v' '-Wall' '-c' '-fmessage-length=0' '-MMD' '-MP' '-MF' 'src/ESA_SPI.d' '-MT' 'src/ESA_SPI.o' '-o' 'src/ESA_SPI.o' '-march=armv7-a' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu' /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/cc1 -quiet -v -I -I/usr/loca

                  L Offline
                  L Offline
                  leon de boer
                  wrote on last edited by
                  #10

                  If that is for a Pi2 the compiler settings I find really strange usually it is -mfpu=neon -mfloat-abi=hard -march=armv7ve -mtune=cortex-a7 Must be a funky linux thing which I avoid like the plague, I only baremetal the Pi. You see by my baremetal samples I always run those settings as they are optimal LdB-ECM: Raspberry Pi samples[^]

                  In vino veritas

                  V 1 Reply Last reply
                  0
                  • L leon de boer

                    If that is for a Pi2 the compiler settings I find really strange usually it is -mfpu=neon -mfloat-abi=hard -march=armv7ve -mtune=cortex-a7 Must be a funky linux thing which I avoid like the plague, I only baremetal the Pi. You see by my baremetal samples I always run those settings as they are optimal LdB-ECM: Raspberry Pi samples[^]

                    In vino veritas

                    V Offline
                    V Offline
                    Vaclav_
                    wrote on last edited by
                    #11

                    It is for Pi 3B. I am currently looking into autotools. I got the x86 system to compile, link and actually run. You made a good point these "system designators " are a mess. The autotool uses three of them and naturally can identify the one where the Eclipse resides - on x86. And they call it "build" (platform) , than the "host" is where the ARM - Raspberry is. Exactly opposite of Eclipse terminology! This terminology just does not jive with plain "debug" and "release" I am accustomed in C / C++. It actually looks as both "build" and "host" are compiled / linked same time. Using -v verbose option whenever I can! The intergeneration of autotools into Eclipse stinks. Too many "make" files with no way to easy see how they interact. Cheers Vaclav

                    L 1 Reply Last reply
                    0
                    • V Vaclav_

                      It is for Pi 3B. I am currently looking into autotools. I got the x86 system to compile, link and actually run. You made a good point these "system designators " are a mess. The autotool uses three of them and naturally can identify the one where the Eclipse resides - on x86. And they call it "build" (platform) , than the "host" is where the ARM - Raspberry is. Exactly opposite of Eclipse terminology! This terminology just does not jive with plain "debug" and "release" I am accustomed in C / C++. It actually looks as both "build" and "host" are compiled / linked same time. Using -v verbose option whenever I can! The intergeneration of autotools into Eclipse stinks. Too many "make" files with no way to easy see how they interact. Cheers Vaclav

                      L Offline
                      L Offline
                      leon de boer
                      wrote on last edited by
                      #12

                      Correct settings for a Pi3 are -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv8-a -mtune=cortex-a53 But I am questioning if you might have to match the compiler settings for the O/S which may even be for an ARM6 given the O/S distribution probably runs on a Pi1.

                      In vino veritas

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups