I'm compiling a shared lib (.so) that use log4cxx library. I'm getting the following error:
liblog4cxx.a(level.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
Have you any idea? should I recompile log4cxx with some special option?
You are trying to link your shared library to a static library (
liblog4cxx.a), which does not work, because all ingredients to a shared library must be compiled with the-fPIC(position independent code) option. Static libraries (typically seen with the*.afile suffix) are typically not compiled with this option.Your problem could be caused by two different issues. Either the liblog4cxx library is also present as a shared library and your linker somehow does not find it and tries to use the static library instead, or the shared version of liblog4cxx is missing in your installation.
I therefore advice to look for the path where the
liblog4cxx.afile is located (e.g. in/usr/libor another directory if you installed the library in a custom directory) and then look for aliblog4cxx.soin the same directory. If you found a shared version you could try to explicitly specify the path to your linker with-l/full/path/to/your/liblog4cxx.so.If there is no shared version of the library I'm afraid, that you must reconfigure it to produce a shared library and than recompile it.
For a more specific help, you should give some more background information, as the build process of c++ libraries and projects is highly system dependend. So try to give information as