[Top][All Lists]

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

Re: automatic link specification

From: AlfC
Subject: Re: automatic link specification
Date: Mon, 17 Sep 2007 08:09:43 -0000
User-agent: G2/1.0

On Sep 16, 9:09 am, Paul Pluzhnikov <>
> AlfC <> writes:
> >  Is there any way to tell g++ to link to specific libraries from
> > within the source code,
> No.
> Why do you think it's a good idea to be able to do this?

For example, suppose  that you write a header file that uses
boost_filesystem internally, from them on you will need *always* to
compile with the option -lboost_filesystem. (at most you can specify
different version of the file but it will be always something like
this, there is not much variation from then on)

Let's say that you give your source code that is "script-like" to
someone else, she should know implementation details about some
library called boost_filesystem that she never heard about and worst ,
the compilation gives awful errors messages about linking that don't
help in figuring out to which object file to link.
I could write a comment after "#include<boost/filesystem.hpp>" such as
"/* don't forget to link to -lboost_filesystem*/" but then I thought,
well, maybe gcc can do this for me and for the other user and I can
just write "#include<boost/filesystem.hpp>  #gcc_auto_link
I don't know, I thought it could be easier for script-like programs,
besides it is not standard, why do you think it is a *bad* idea to be
able to do this?

the closest I could get was to add a line "#warning 'remember to link
to -lboost_filesystem'" just bellow some include line, but it is still
annoying because the message still shows up when you do add the option

Thanks for your response.

reply via email to

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