Error: recompile with -fpic when try to install Armadillo - makefile

I was trying to install Armadillo in my Ubuntu 14.04.
I run cmake . command in the terminal at the folder where the Armadillo files are located and then run make command. I got the following errors.
/usr/bin/ld: /usr/local/lib/libsuperlu.a(util.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;
recompile with -fPIC
/usr/local/lib/libsuperlu.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libarmadillo.so.7.800.1] Error 1
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
make: *** [all] Error 2
How can I rectify this?

The library at /usr/local/lib/libsuperlu.a on your system was most likely not built with -fPIC and you are presumably trying to build a shared library that uses code from libsuperlu.a. If this is your situation, then the compiler is telling you that the code in libsuperlu.a is not relocatable, but your shared library needs it to be. You will need to build your own libsuperlu.a and ensure that all of its object files are compiled with the -fPIC flag, since the libsuperlu.a you currently have installed in /usr/local/lib won't work for you.

Related

How to rebuild libiberty.a with -fPIC flag

I've getting the following linking error while compiling mlpack:
[ 37%] Linking CXX shared library ../../lib/libmlpack.so
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib/libiberty.a(cplus-dem.o): warning: relocation against `libiberty_demanglers' in read-only section `.text'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib/libiberty.a(cp-demangle.o): relocation R_X86_64_PC32 against symbol `cplus_demangle_builtin_types' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/mlpack/CMakeFiles/mlpack.dir/build.make:1040: lib/libmlpack.so.3.4] Error 1
make[1]: *** [CMakeFiles/Makefile2:2106: src/mlpack/CMakeFiles/mlpack.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
It seems I need to recompile libiberty.a library with -fPIC flag. How do I do that?
I found this bug report on the issue. In my case I was able to fix things by downgrading a few packages (as described in the report):
binutils 2.36.1-3
gcc 11.1.0-3
gcc-libs 11.1.0-3
gcc fortran-11.1.0-3
Ultimately this should be resolved when binutils gets updated.

Trying to compile erlang program using erlang.mk

am trying to compile erlang code using command 'make' on erlang.mk and getting the below error. i dont know where to go from here. am new to erlang.mk and erlang. am on ubuntu
Getting Xabber Web client .... done.
Copying Xabber Web files to 'priv' directory ........ done.
make[1]: Entering directory '/home/isachi2004/xabber-websocket
/deps/fast_xml'
cc -o priv/lib/fxml.so c_src/fxml.o -lexpat -L -lei -shared
/usr/bin/ld: cannot find -lexpat
collect2: error: ld returned 1 exit status
c_src/Makefile.erlang.mk:24: recipe for target 'priv/lib/fxml.so'
failed
make[2]: *** [priv/lib/fxml.so] Error 1
Makefile:25: recipe for target 'pre-app' failed
make[1]: *** [pre-app] Error 2
make[1]: Leaving directory '/home/isachi2004/xabber-websocket
/deps/fast_xml'
erlang.mk:4512: recipe for target 'deps' failed
make: *** [deps] Error 2
This error means that it cannot find the development files for the Expat library (an XML parser):
/usr/bin/ld: cannot find -lexpat
On Ubuntu, you could try installing it with:
sudo apt install libexpat1-dev

Yocto Jethro: How to choose a Yocto Default Compiler? glibc failed at do_compile when use gcc 4.9

Because of old Das u-boot from HEAD branch that do not have gcc 5 yet, I am planning on using gcc 4.8 or 4.9 as a default compiler instead of 5.2.
GCC required virtual/libc glibc-2.22. glibc-2.22 complied successfully with 5.2. Unfortunately, it failed at do_compile with the error: ld: cannot find -lgcc with gcc 4.8 and 4.9
arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/yocto/hio-jethro/build-hio/tmp/sysroots/hio-imx6dl-board-tcbootstrap -nostdlib -nostartfiles -r -o /yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/build-arm-poky-linux-gnueabi/elf/librtld.map.o '-Wl,-(' /yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/build-arm-poky-linux-gnueabi/elf/dl-allobjs.os /yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/build-arm-poky-linux-gnueabi/libc_pic.a -lgcc '-Wl,-)' -Wl,-Map,/yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/build-arm-poky-linux-gnueabi/elf/librtld.mapT
/yocto/hio-jethro/build-hio/tmp/sysroots/x86_64-linux/usr/bin/arm-poky-linux-gnueabi.gcc-cross-initial-arm/../../libexec/arm-poky-linux-gnueabi.gcc-cross-initial-arm/gcc/arm-poky-linux-gnueabi/5.2.0/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
make[2]: *** [/yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/build-arm-poky-linux-gnueabi/elf/librtld.map] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/git/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/yocto/hio-jethro/build-hio/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/glibc/2.22-r0/git'
make: *** [all] Error 2
ERROR: oe_runmake failed
Am I looking at the right error? and How do I add -lgcc?
Edit:
I have checked with Fido Branch and everything is working fine. I might just need replace gcc and glibc with Fido's
How did you tell it to use GCC 4? The paths are still referencing 5.2.0, which suggests that you didn't change it correctly. The correct way to change GCC version is to set GCCVERSION, ie GCCVERSION="4.%".
Also u-boot in jethro supports gcc5 just fine, so why are you using an old release?

Giza++ installation, FORTRAN problems

I am trying to install Giza++ and Moses on Ubuntu 12.10 64bit. While make I keep on getting the same problem:
Finished building giza
cp ../lib/libgiza.a /usr/local/lib/
................................
giza-pgplot.o -L/usr/X11R6//lib -lX11 -L/usr/X11R6//lib -lcairo -lm -L/usr/local /lib/x86_64/ -lgfortran
/usr/bin/ld: giza-fortran.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
giza-fortran.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[1]: *** [../lib/libpgplot.so] Error 1
make[1]: Leaving directory `/home/maria/moses/giza/build'
make: *** [install] Error 2 "
Googling did not help much. I would be very grateful for any tip of how to solve this problem. What should I do to recompile it with -fPIC?
This problem existed only with the giza check out from the svn. This one from tar.gz http://code.google.com/p/giza-pp/downloads/list installed without any problems. Whatever it was...

gcc cross compile linker error: could not read symbols: File format not recognized collect2

I'm trying to cross compile a package applicaiton with gcc-eabi. I have modified the configuration file to point to all the target directories. But the linker still gives an error when linking some shared libraries. The exact error is below:
Linking CXX shared library /home/aeodrs/JAUS++-2.110519-src/libraries/jaus++/2.0/lib /libcxutils.so
/home/aeodrs/JAUS++-2.110519-src/libraries/jaus++/2.0/lib/libcxjpeg-6b.a: could not read symbols: File format not recognized collect2: ld returned 1 exit status
make[2]: *** [/home/aeodrs/JAUS++-2.110519-src/libraries/jaus++/2.0/lib/libcxutils.so] Error 1
make[1]: *** [libcxutils/CxUtils/libcxutils/CMakeFiles/cxutils.dir/all] Error 2
make: *** [all] Error 2
aeodrs#ubuntu:~/JAUS++-2.110519-src/libraries/jaus++/2.0/build/cmake$
I'm not sure why the linker can't read or is corrupting the library file.

Resources