I also tried linking with g++ (not something I'm used to) by following the following JNI example from Sun and got the following error: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html [exec] g++-4.5 -o libparallelsurflib.so -shared -Wl,-soname,parallelsurf.so -I/usr/lib/jvm/java-6-openjdk/include/ -I/usr/lib/jvm/java-6-openjdk/include/linux/ parallelsurf_jni.cpp -static -lc /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.5.1/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-linux-gnu/4.5.1/crtbeginT.o: could not read symbols: Bad value collect2: ld returned 1 exit status Adding -fPIC doesn't seem to help. I added it before the source file name at first, but when that failed, tried a few locations in case I had the command order incorrect. On Feb 27, 2011, at 2:07 PM, Jonathan Wakely wrote: > On 27 February 2011 18:59, Andrew Richardson <a.chardson@xxxxxxxxx> wrote: >> Either Ubuntu 10.10 (or my personal standard package list -- I just >> installed 10.10 today) already comes with libstdc++6-4.4-dev. Just for fun, >> I installed libstdc++6-4.5-dev. I also grabbed libgcj11-dev, but I get the >> same error. Here's the output of the makefile: >> [exec] javah -classpath ../../parallelsurf.jar -jni >> parallelsurf.ParallelSURF >> [exec] g++ -Wall -lstdc++ -shared -O2 -c -fPIC -D_REENTRANT >> parallelsurf_jni.cpp -I/usr/lib/jvm/java-6-openjdk/include/ >> [exec] ld -l stdc++ --shared parallelsurf_jni.o -o libparallelsurf.so >> >> I can confirm that /usr/lib/gcc/x86_64-linux-gnu/4.5/ contains libstdc++.a >> and (in /usr/lib). There's also a symlink there (libstdc++.so --> >> /usr/lib/libstdc++.so.6). Since ld couldn't find libstdc++.so, I thought it >> might not know about this directory and might not know about other important >> bits there. I added it to the search path for ld (-L /usr/lib/gcc/...) and >> built again. No improvement (still __gcj_personality_v0) > > If you link with g++ instead of ld that shouldn't be necessary, but I > don't think that's the problem.