View Full Version : Building a shared library on Fedora Core 2

17th November 2004, 04:11 PM
Hi all,

I have a command-line C program compiled under gcc on my 64 bit fedora core 2 box, all working very well.
Now I wish to package the C source into a shared object, to be called from another java program (java 1.5 for 64 bit linux)

I build my shared object as follows:

gcc -c -fPIC <c source files>
gcc -fPIC -shared <obj files> -o liblibrary.so

...which all works fine. I then put the .so into a place it can be found at runtime.

However, when I run the java project, it successfully kicks off the .so, but crashes in the middle of one of my C routines.

I have recompiled and run the same project on Windows using a DLL, with success. So my suspicions are that I have somehow incorrectly built my .so.

Any help is greatly appreciated,


23rd November 2004, 04:45 PM
I suppose you could try the -m64 flag. It's an interesting question whether the gcc compiler on a 64 bit machine knows to default so it generates 64 bit code. I've been compling and running programs on mine and never stopped to think about whether I was getting a 64 bit executable! Haven't tried any shared objects.