views:

14

answers:

1

I am trying to reverse engineer a previous employee's build process for some custom software he wrote for us. I've seen to get everything to compile okay, but I get an error in the linking process that points to a problem with crypto++. Any clues?

compile.util:

compile:
     [echo] Compiling: util
       [cc] Starting dependency analysis for 55 files.
       [cc] 55 files are up to date.
       [cc] 0 files to be recompiled from dependency analysis.
       [cc] 0 total files to be compiled.

link.util:

link:
     [echo] Linking shared library: libutil
       [cc] 0 total files to be compiled.
       [cc] Starting link
       [cc] /usr/bin/ld: /home/john/softwarename/thirdparty/crypto/5.6.1_64/libcryptopp.a(cryptlib.o): relocation R_X86_64_32 against `CryptoPP::DEFAULT_CHANNEL' can not be used when making a shared object; recompile with -fPIC
       [cc] /home/john/softwarename/thirdparty/crypto/5.6.1_64/libcryptopp.a: could not read symbols: Bad value
       [cc] collect2: ld returned 1 exit status

BUILD FAILED
/home/john/softwarename/build/build.xml:167: Following error occured while executing this line
/home/john/softwarename/build/link.xml:27: gcc failed with return code 1

Os is Fedora 11

+1  A: 

Every object file you link into a shared library must be position independent, meaning the loader can move it wherever it wants in memory and it will still work. Your crypto library was not compiled that way, hence the admonition to recompile it with -fPIC added to your compile flags. Alternately, you can make libutil a static library instead of a shared one. Without more details on your build files, I can't provide more details on how to do that or which one to choose.

Karl Bielefeldt
Upon further investigation, I think that my ANT build file is expecting a `libcryptopp.so` in my crypto directory. But after downloading the crypto++ source and running `make`, it creates a bunch of .o files and a libcryptopp.a file. How do I get my required libcryptopp.so file? I'm new to GCC and ANT so sorry if this sounds like a noob compiling question.
Jakobud
In the makefile inside the crypto directory, add `-fPIC` to the end of `CXXFLAGS`, then do a `make clean` and try again.
Karl Bielefeldt