clinuxzeromqfpic

undefined stat symbol after compiling with -fPIC


I'm using an (static) external library (zmq.a) in our code, and during the compilation process of our program it says

../libzmq.a(src_libzmd when making a shared object; recompile with -fPIC

However if I compile the library itself with -fPIC, our code now compiles but I received an error on launch: "undefined symbol stat"

Edit: I use the following commands in order to generate libzmq.a (on rdht 7 x86):

autoreconf --install && mkdir build && cd build && ../configure && make CFLAGS='-fPIC' CXXFLAGS='-fPIC' && make install


Solution

  • Okay, so I was able to solve it. The way I changed the CFLAGS etc. overrided the other flags, I needed to just add the '-fPIC' instead. One of the overrided flags was '-O2' therefore it couldn't find the stat symbol (as can be seen from the suggested answer before).