How to link a library statically in a binary

A

ankur.cdac

I have Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 compiler running on
SunOS 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-60 machine.

i am using /opt/SUNWspro/bin//CC for building C++ code.
I want to link a shared library libxyz.so to my binary satically, so
that i may not need that at run time.
i used -staticlib=xyz but its not working . Its saying that
CC: Warning: illegal option xyz ignored

I included the path in PATH and LD_LIBRARY_PATH both but still the
problem didnt get solved.
Please suggest that what to use in thatis case.
 
D

Dirk Krause

(e-mail address removed) wrote in 75g2000cwc.googlegroups.com:
I have Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 compiler running on
SunOS 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-60 machine.

i am using /opt/SUNWspro/bin//CC for building C++ code.
I want to link a shared library libxyz.so to my binary satically, so
that i may not need that at run time.
i used -staticlib=xyz but its not working . Its saying that
CC: Warning: illegal option xyz ignored

I included the path in PATH and LD_LIBRARY_PATH both but still the
problem didnt get solved.
Please suggest that what to use in thatis case.
On my system (probably another Workshop version) there
are options "-B dynamic -dy" or "-B static -dn". For static
linking you need a file libxyz.a, not libxyz.so.
For both options "-B static" and "-dn" the manpage contains
a warning that some system libraries (i.e. libc) are available
as shared libraries only. So you should switch back to
dynamic linking at the end of your command line and allow
the linker to use the shared system libraries.
Hope this helps.

Regards,

Dirk

PS: Your question is more a candidate for a
"programming on Solaris"-related newsgroup than for a newsgroup
about general C (not C++, no system/compiler specific) problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,096
Latest member
ThurmanCre

Latest Threads

Top