Andrew,
Let's go over the facts.
*) All my files are compiled with -fPIC and always were.
*) When I compile I build the basic library, called libroc.a, so it
is static.
I mean it to be static so I can give it to people and they don't
need gfortran.
The library works fine, whether I add the .o from libgfortran.a (ar -
x librgfortran.a),
or whether I compile invoking libgfortran.a from g++.
*) The library.a can be linked and works from any Linux X86_64 that I
could find.
*) The jni library, the dynamically linked library and all the rest
compiles, builds and runs fine on OS X, Windows and Linux 32.
However, when I try to build a dynamically linked library to be
loaded by java, including the .o files from libgfortran.a
% g++ -shared -fPIC -o libroc.so -I/usr/java/jdk/include -I/usr/java/
jdk/include/linux rocJniFortran_LINUX.c libroc.a
/usr/bin/ld: libroc.a(close.o): relocation R_X86_64_32 against `a
local symbol' can not be used when making a shared object; recompile
with -fPIC
libroc.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
Note that all the pieces of java are in place and EVERY piece of my
library is built using -fPIC.
If I do not include the .o files from libgfortran:
g++ TestGetAzValue_LINUX.cpp libroc.a /usr/lib/gcc/x86_64-redhat-
linux/4.1.1/libgfortran.a
I did not follow this path because I expect that when java will load
the library on a different machine it will be
looking for a suitable libgfortran.so and die if it isn't there.
The java does this to me.
java: symbol lookup error: /Projects/ROC/users/lpesce/ROC/java/
libroc.so: undefined symbol: _gfortran_internal_malloc64
Which perhaps means that it can't find the library or ...
Remember that this project, as is, works perfectly fine on nearly
every other system.
It does not work on gcc-4.2 and above because of what seems to be a
pesky bug in that release (for Linux only, I build on on gcc-4.3 on
OS X).
I might be wrong about all of it, of course.
Lorenzo