By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,118 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,118 IT Pros & Developers. It's quick & easy.

How to link a library statically in a binary

P: n/a
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.

Jul 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
an********@gmail.com wrote in news:1152706777.973306.129780@
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.
--
Dirk Krause
Please do not respond to the e-mail address shown in the newsreader.
Use the web form below instead. Thanks.
http://www.fh-schmalkalden.de/url.ph...lect_wert/3023
Jul 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.