-fPIC flag is not working, JNI problem
-
I try to link the fftw3f library to a java project within the standard JNI framework.
A Java test program runs successfully. The library is found.
I can make a call the native function:fftwf_malloc
However, as soon as I make a call to the native functions:
fftwf_plan_dft_r2c_2d
and
fftwf_execute(plan)
the linking of the dynamic library fails with the following error message:
/usr/bin/ld: //usr/local/lib/libfftw3f.a(assert.o): relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit statusI use the following command to create the object files:
g++ -m64 -Wall -fPIC -shared -c -I./.. -Itarget/custom-javah -I/usr/lib/jvm/java-8-oracle/jre/../include -I/usr/lib/jvm/java-8-oracle/jre/../include/linux -otarget/objs/convolutionWrapper.o -c ../convolutionWrapper.cpp -lfftw3f -lm
and the following command to create the library:
g++ -o target/lib/libnativeConvolution.so -fPIC -shared target/objs/convolutionWrapper.o -lfftw3f -lm -lc
I tried various positions of the flags and also omitted the libraries while creating the object files.
Any help is appreciated.
-
An welcher Stelle ist da eine Frage zu C++?
-
Dieser Thread wurde von Moderator/in SeppJ aus dem Forum C++ (alle ISO-Standards) in das Forum Rund um die Programmierung verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
The fftw library had to be recompiled using the flag --enable-shared.
./configure --enable-shared
make
sudo make install