I needed to build FFTW (Fastest Fourier Transform in the West) at work so we could load it as a shared object. We want to load FFTW via JNI/JNA from Java to speed up our FFT calculations. To use JNI you use its loadLibrary() or JNA its register() or loadLibrary function calls and those only work with shared libraries and also in particular on x86_64 you need to make them Position Independent Code or the "-fPIC" option has to be used (or at least I've never been able to use JNI or JNA without the shared library being PIC-ized to coin a word)
The problem I had was that it seemed I should run configure as this (I did two because I wanted both
the single and double precision versions):
Quote:
configure --prefix=<path to installation>/fftwsingle --enable-shared --with-pic --enable-single
configure --prefix=<path to installation>/fftwdbl --enable-shared --with-pic --enable-sse2
|
the first configure is for single precision and the second is to make a double precision version and
to speed up the double case I added sse2 support (not an option with single precision so I didn't use that option there). Also there was no particular option for double precision because double is the default.
The problem is that I then ran "make" and get this error:
Quote:
relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object;
recompile with -fPIC
|
It turned out that I couldn't get the --with-pic to work as expected on x86_64, so I dropped that option
from both my configure commands and then edited the Makefiles to add "-fPIC" to the CFLAGS option list and ran the 'make' as usual and the make install as usual so my procedure step by step was:
Quote:
configure --prefix=<path to installation>/fftwsingle --enable-shared --with-pic --enable-single
<edit Makefile to add -fPIC to CFLAGS>
make
make install
configure --prefix=<path to installation>/fftwdbl --enable-shared --with-pic --enable-sse2
<edit Makefile to add -fPIC to CFLAGS>
make
make install
|
This seems to work. I suppose this particular situation (building FFTW as PIC shared objects on x86_64) doesn't happen much but I suspect this PIC failure will happen with other products and not just FFTW and I think this editing in the -fPIC by hand might help.