Need help linking (Sun Workshop 6 CC)
Hi list,
I am experiencing a problem with exporting functions in a shared library that I am building with Sun Workshop. I am compiling my C code using the following format:
/opt/SUNWspro/WS6U2/bin/cc -c -mt -xO4 -Kpic -s -misalign -xCC -xchar -xipo -D_REENTRANT -I./INCLUDE -I./PLATFORM/INCLUDE -o file1.o file1.c
I am linking my archives with the following command:
/opt/SUNWspro/WS6U2/bin/CC -xar -o libfiles1.a file1.o file2.o file3.o
Then I am building my shared object library with the following command:
/opt/SUNWspro/WS6U2/bin/cc -dy -Bdynamic -M lib-SOLARIS.def -G -h libfiles.so.1.1.1 -o libfiles.so.1.1.1 libfiles1.a libfiles2.a libfiles3.a file9.o
Notice that when I am linking the shared library I am linking archives, objects and maybe even other shared libraries.
The build works but I am getting undefined symbols in the shared libraries.
Anything obviously wrong here?
Thanks.
# 2
Also, there is a number of compiler flags that should be specified both on compile and link command line.One of those is -xipo, which you did you to compile your .o's.You can find a full list of those "specific" options in a user guide.regards,__Fedor.
SFVa at 2007-7-7 16:10:45 >

# 3
[code]
/opt/SUNWspro/WS6U2/bin/cc -dy -Bdynamic -M lib-SOLARIS.def -G -h libfiles.so.1.1.1 -o libfiles.so.1.1.1 libfiles1.a libfiles2.a libfiles3.a file9.o
[/code]
I don't think the above will place your .a in .so
Only the .o which are required will be extracted and put in the .so
This might be the reason.
# 5
The solution that worked for me was to add -z rescan to the link command. I also added -z allextract but I don't know that it was necessary. Turns out I had some recursive dependancies that were not resolving during the link as I had it.
Thanks for the suggestions, though. Hope this helps someone in the future.
# 6
Just for the record, I think -z allextract is the magic option.
It causes all the contents of the archive libraries to get put
into the shared library regardless of whether their symbols are
referenced by the initial code preceding the archive library
on the link line.
--chris