3

I'm trying to install Caffe on Debian, but when i do make all i get this error:

/usr/bin/ld: /usr/local/lib/libglog.a(logging.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

/usr/local/lib/libglog.a: could not read symbols: Bad value

collect2: error: ld returned 1 exit status make: *** [.build_release/lib/libcaffe.so] Error 1

where should i add the -fPIC flag? I also read that it wasn't enough for gflags.

Any suggestions?

user2071581
  • 183
  • 2
  • 13
  • Does Caffe have documentation on adding to any specific `CFLAGS`-like variable? You might also want to report to them that their build is broken (because it is) and that they should be handling this themselves. – Etan Reisner Nov 10 '15 at 17:10
  • i can't find any documentation about adding specific `CFLAGS` – user2071581 Nov 10 '15 at 17:35
  • Oh, hm, I hadn't properly read that error. That might be an issue with how you compiled the `glog` library. (I assume you compiled that yourself.) You might need to recompile *that* library with `-fPIC`. – Etan Reisner Nov 10 '15 at 18:19
  • after some tries i solved recompiling `glog` and `gflags` with `-fPIC` thank you :) – user2071581 Nov 11 '15 at 00:02
  • If you can write up your solution you should add it as an answer here and accept it. You might also want to report this to the `glog` people. – Etan Reisner Nov 11 '15 at 02:42
  • I have the same error but with libboost-python.a `/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libboost_python.a(dict.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC` – spiderface Nov 02 '16 at 14:55

2 Answers2

0

Seems like the only solution in to recompile the problematic 3rd parties with -fPIC. (Unless you can link to the .so instead of the .a)
The standard build of static libraries in packages is to build without -fPIC.
In glog, for example, you should add it to the C flags in compile.ac.

rkellerm
  • 5,362
  • 8
  • 58
  • 95
0

In glog, adding -fPIC to AM_CXXFLAGS in Makefile.am works. Adding it to the CXXFLAGS environment variable had no effect for me.

nnnmmm
  • 7,964
  • 4
  • 22
  • 41