Question

I have two autotools-based projects AAA and BBB:

  • AAA is built with "--enable-static --disable-shared", all code written in C
  • BBB is a dynamic library, and links against AAA using "libBBB_la_LIBADD = /path/to/libAAA.a"

I'm getting the following when trying to compile BBB:

/usr/bin/ld: /usr/local/lib/libAAA.a(liboAAA_la-foo.o): relocation R_X86_64_PC32 against undefined symbol `malloc@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

For reference, the actual command that's generating the error is:

gcc -shared  -fPIC -DPIC  .libs/libBBB_la-BBB.o .libs/libBBB_la-hash.o .libs/libBBB_la-vl_helpers.o   -lm -L/usr/local/lib /usr/local/lib/libAAA.a  -O3   -Wl,-soname -Wl,libBBB.so.0 -o .libs/libBBB.so.0.0.0

What am I doing wrong, and how do I make this work?

Was it helpful?

Solution

libAAA should be built with -fPIC to get position-independent code. In the current setup, you're trying to build a mixed PIC/non-PIC libBBB, which is not allowed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top