0

When I build a project with cmake, I got following error. Though I tried to add compiling flag -fPIC by add_definition() in the CMakeLists.txt, this error persists. Can anyone help? I am a new guy to . Any suggestions will be highly appreciated.

/usr/bin/ld: /act/mvapich2-1.9/gcc-4.7.2/lib/libmpich.a(mvapich_malloc.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
/act/mvapich2-1.9/gcc-4.7.2/lib/libmpich.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/libstracker.so] Error 1
make[2]: Leaving directory `/home/xxxx/success/AutomaDeD-master'
make[1]: *** [src/CMakeFiles/stracker.dir/all] Error 2
make[1]: Leaving directory `/home/xxxx/success/AutomaDeD-master'
make: *** [all] Error 2
Peter Petrik
  • 9,701
  • 5
  • 41
  • 65

1 Answers1

1

add_definitions is is intended to add preprocessor definitions, not a flag

-fPIC is present by default in the linker flags for a shared library build with GCC, see Modules/Compiler/GNU.cmake. You can see all flags by running make VERBOSE=1.

As for the error itself, see this answer.

Community
  • 1
  • 1
Peter Petrik
  • 9,701
  • 5
  • 41
  • 65