View Full Version : Shared Library
Kinasz
10-07-2002, 06:29 AM
Can someone explain how to compile source to be a shared library?
Kinasz
10-07-2002, 07:00 AM
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?
Kinasz
10-07-2002, 07:03 AM
I should mention I'm new to C++, I'm trying to do it so I can use C code with my java programs.
rohit
10-07-2002, 07:12 AM
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
Kinasz
10-07-2002, 08:11 AM
Thanx for the help
Couldnt get it to work but I think it is the Java Native Interface that is stuffed up.
-Kinasz
Captain
10-07-2002, 09:25 AM
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.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.