Can someone explain how to compile source to be a shared library?
Can someone explain how to compile source to be a shared library?
Yeh all I could find was this
-shared
Produce a shared object which can then be linked
with other objects to form an executable. Only a
few systems support this option.
It didnt really tell me much, I you do know how to do it could you please help?
I should mention I'm new to C++, I'm trying to do it so I can use C code with my java programs.
say you have two files
main.c and lib.c
you will make a.out from main.c and mylib.so from lib.c
here it goes
cc -c -o libmylib.o lib.c -fPIC
cc -shared --wall,--soname,"mylib.so.0" -o libmylib.so libmylib.o
copy your libmylib.so to /usr/lib
cd to /usr/lib
create a link mylib.so.0 and point to libmylib.so.o
ldconfig and next time when your compile use "-lmylib"
cheers
Thanx for the help
Couldnt get it to work but I think it is the Java Native Interface that is stuffed up.
-Kinasz
You might want to ask where the control for linked libraries are maintained. They are most probably maintained on the kernel side (except not in a virtual machine where the kernel is emulated on the user side). My guess is that you will have to perform system calls, or at least your compiler will have to do that.