1 Reply Latest reply on 10-Apr-2014 18:19 by Lukas Snetler

    Build a shared library for DS-5

    bobo Bit

      I am trying to run the Armadillo Linear Algebra package on my Altera Cyclone V.


      Armadillo: C++ linear algebra library


      I get it to work with general Linux GCC and it runs on my Red Hat computer


      Invoking: GCC C++ Compiler
      g++ -I/usr/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Armadillo_Test.d" -MT"src/Armadillo_Test.d" -o "src/Armadillo_Test.o" "../src/Armadillo_Test.cpp"
      Finished building: ../src/Armadillo_Test.cpp

      Building target: Armadillo_Test
      Invoking: GCC C++ Linker
      g++ -L/usr/lib64 -o "Armadillo_Test"  ./src/Armadillo_Test.o   -lm  -larmadillo  -llapack  -lblas  -larpack
      Finished building target: Armadillo_Test


      When I try to use the DS5 tool chain I get


      Invoking: GCC C++ Compiler

      arm-linux-gnueabihf-g++ -I/usr/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Armadillo_Test.d" -MT"src/Armadillo_Test.d" -o "src/Armadillo_Test.o" "../src/Armadillo_Test.cpp"

      Finished building: ../src/Armadillo_Test.cpp


      Building target: Armadillo_Test

      Invoking: GCC C++ Linker

      arm-linux-gnueabihf-g++ -L/usr/lib64 -o "Armadillo_Test"  ./src/Armadillo_Test.o   -lm  -larmadillo  -llapack  -lblas  -larpack

      /usr/lib64/libarmadillo.so: file not recognized: File format not recognized

      collect2: error: ld returned 1 exit status


      So it works with g++ but not with arm-linux-gnueabihf-g++.  How should I build the library?  I just built the default way.  cmake .   make  and make install.  Any ideas what I should do?  Can I even run this library on the Cyclone?

        • Re: Build a shared library for DS-5
          Lukas Snetler Employee

          Hi bobo,


          Looks like the last command is failing because it is trying to link against host libraries (from /usr/lib64) which are probably not compiled for ARM architecture. If you were compiling on your target then this would not be a problem. As we are cross compiling here, things are slightly tougher.


          The steps taken to build libarmidillo.so from this post look promising http://stackoverflow.com/questions/21263427/cross-compiling-armadillo-linear-algebra-library


          To help link your applications the gcc compiler in DS-5 provides two differently built libc system root’s, hardfloat (hf) and softfloat, but ideally you’d want to link against the system root built for your device. To include headers you could point to DS-5/sw/gcc/arm-linux-gnueabihf/libc/usr/include/; and select the appropriate system libraries from DS-5/sw/gcc/arm-linux-gnueabihf/libc/usr/lib.


          As long as you are building for an ABI that is compatible with your target filesystem ABI then your application should run (presuming the C libraries are compatible; older versions are normally compatible with newer ones).  You can specify the ABI by selecting a combination of the appropriate –mfloat-abi and –mfpu switches, but I think the default for is hardfloat for arm-linux-gnueabihf.


          Hope this helps

          1 of 1 people found this helpful