help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linking only one library statically?


From: Matthias
Subject: Re: Linking only one library statically?
Date: Sun, 30 Jan 2005 17:05:27 +0100
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Paul Pluzhnikov wrote:
Matthias <nospam@digitalraid.com> writes:


I know that ld has a flag called static.


Only *some* ld's understand '-static'. It is not a "universally
understood" flag.

Gcc/g++ always understands '-static' and translates it into the
appropriate linker flags are OS depend.


But what if I don't want ALL
libs to be statically linked, but only some?


It is impossible to answer your question without knowing the OS.
However, taking an educated guess that you are on Linux, the
answer is:

   g++ ... main.o ... -Wl,-Bstatic -lboost -Wl,-Bdynamic -lgtkmm ...

Be sure *not* to do this:

   g++ ... main.o ... -lgtkmm -Wl,-Bstatic -lboost

The above is wrong because it leaves '-Bstatic' "hanging". It will
cause other libraries (e.g. libc, libstdc++, which are added to
the link line by 'g++') to be linked statically as well, and
will result in much grief later on.

Cheers,

Yep, I am on linux, using g++ 3.3.4. Sorry, forgot to mention that.

Thanks for your reply, I'll try that immediately after today's work is done :)

By the way, what does -Wl do?


--
Regards,
Matthias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]