471,052 Members | 1,215 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,052 software developers and data experts.

How to link a library statically in a binary

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
1 2164
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.

Similar topics

7 posts views Thread by BekTek | last post: by
43 posts views Thread by Steven T. Hatton | last post: by
1 post views Thread by David Douthitt | last post: by
2 posts views Thread by Angel Lopez | last post: by
2 posts views Thread by Egbert Nierop \(MVP for IIS\) | last post: by
4 posts views Thread by danip | last post: by
2 posts views Thread by Chameleon | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.