vresh
asked on
Writing MakeFile for generating a .so file
I need to write a makefile which creates a .so file
from .cpp files. Can somebody help me in providing me with this sample makefile.
Please also provide me with links to help me in writing makefiles
I tried doing a man but it it is too complicated for me.
A tutorial would be helpfull.
from .cpp files. Can somebody help me in providing me with this sample makefile.
Please also provide me with links to help me in writing makefiles
I tried doing a man but it it is too complicated for me.
A tutorial would be helpfull.
which platform?
ASKER
Platform is Solaris 2.6
ASKER
Platform is Solaris 2.6
Elfie, I also require to know how to write a make file.... Thanks
Elfie, I also require to know how to write a make file.... Thanks
file.o: file.c
cc -fPIC -c $< -o $@
libxxx.so: file.o
ld -B symbolic -o $@ $<
cc -fPIC -c $< -o $@
libxxx.so: file.o
ld -B symbolic -o $@ $<
ASKER
I require a sample make file to do it and
when i use ld it starts giving me errors like
Undefined first referenced
symbol in file
__builtin_vec_new cstring.o
Sorry to reject your answer
when i use ld it starts giving me errors like
Undefined first referenced
symbol in file
__builtin_vec_new cstring.o
Sorry to reject your answer
You need to pass more information (post Makefile).
Is builtin_vec_new a function which you have defined in your .c file?
Is builtin_vec_new a function which you have defined in your .c file?
ahoffman,
for making an .so doesn't you need to specify the -B option?
-G In dynamic mode only, produce a shared object.
Undefined symbols are allowed.
for making an .so doesn't you need to specify the -B option?
-G In dynamic mode only, produce a shared object.
Undefined symbols are allowed.
I agree, elfie.
I meant ld -dy , sorry (options have changed due to different OS releases):
I meant ld -dy , sorry (options have changed due to different OS releases):
If the function builtin_vec_new is present in a file (or .so) you added to your link command, try changing the order of the file
if you have a line like
ld -o prog library.so file1.0 file2.o,
change it into
ld -o prog file1.o file2.o library.so
If you are using 'ld' to build the program, you need to specify a n umber of system libraries also, so for building your it's better to use 'cc', so easier is
cc -o prog file1.o file2.o library.so
if you have a line like
ld -o prog library.so file1.0 file2.o,
change it into
ld -o prog file1.o file2.o library.so
If you are using 'ld' to build the program, you need to specify a n umber of system libraries also, so for building your it's better to use 'cc', so easier is
cc -o prog file1.o file2.o library.so
hmm, elfie,
order of libs and/.o files should not be essential while using .so libs, .o files are searched first, then all libs
That's one of the advantages of shared objects ;-)
(but ld may have changed its algorithm, I don't know ...)
order of libs and/.o files should not be essential while using .so libs, .o files are searched first, then all libs
That's one of the advantages of shared objects ;-)
(but ld may have changed its algorithm, I don't know ...)
we once had problems (on HP-UX 9.x) that the order of libs linking libs could influence the behavior of programs.
In case where a routine resides in two libraries, it took the first instance, and then search further for other called routines.
Probably not the case here, but ...
In case where a routine resides in two libraries, it took the first instance, and then search further for other called routines.
Probably not the case here, but ...
How about using ar command?
please using
%man ar
to see the detail.
please using
%man ar
to see the detail.
tangyw, we're talking about .so
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It worked but where can I find help on writing makefiles
compile object with options ggc -fPIC
When build ing the .so combine all .o files into an so file, using option -G for ld. so it will be ld -G all_o_files -o file.so