[Scons-users] Change order of parameters in linker call

Bill Deegan bill at baddogconsulting.com
Wed Aug 5 15:17:51 EDT 2015


Dominic,

As one who's asked users to read the documentation, I always (pretty sure
here) point to the section in the Users Guide and/or manpage.  And
occasionally (If I'm not answering from my mobile device and have some time
to do so) copy/paste the most relevant snippet of info into the email.

The variables you've listed are in the manpage.  There's a long list of
variables all together with a description of their function there.   This
is fairly typical manpage structure.

If we listed all the variables which could influence the behavior of each
and every builder/command which goes in a SConstruct/SConscript, it would
be a lot more verbose and (likely) harder to search. manpages are typically
not hyperlinked so you would have to search for CPPPATH (for example) many
many times before you would find the substantive information.

In your specific case, we generally advise people to use LINKPATH and LIBS
as for 80-90% of the builds those are sufficient for setting the linker
command line flags.

I always advise new SCons users to read the whole manpage and the whole
users guide.

Jumping in and trying to use SCons may work fine for you, but if you run
into a problem, you may need to read both those docs to get the subtleties.

Hope that helps!
-Bill


On Wed, Aug 5, 2015 at 12:06 PM, Dominic Binks <dominic.binks at thebinkles.net
> wrote:

> Ah, I see the confusion here and I retract my statement that it's a bug.
>
> But there is still some confusion here which I think the documentation
> needs to clear up.
>
> Conventionally make uses LDFLAGS to specify flags to the linker using LIBS
> to specify the library depenencies.
>
> I think the confusion comes from SCons introducing the variable LINKFLAGS
> in place of LDFLAGS.  I assume this change is due to Microsoft's linker
> being called "link" while Unix linkers are usually "ld" though there is an
> inconsistency here as SCons follows make in the use of CC/CFLAGS/CXXFLAGS
> etc.
>
> However, as a user, when trying to discover how to control a link I'd look
> for three things in the SCons documentation: SharedLibrary() if I was
> building a shared library, Program() if I was building a program and Link()
> for linking something else (e.g. building a relocatable combined object
> file).
>
> If I look up Program() or SharedLibrary() I find no reference to LIBS and
> LIBPATH, or indeed any of the other environment variables that would affect
> this operation.  If I look up Link(), I won't find it since SCons doesn't
> support this notion.  Ok so for linking guess at LIBS and LIBPATH would be
> reasonably obvious but it's not nearly so obvious when trying to do other
> things.  It would be enormously helpful if for each builder described there
> was a list of the environment variables that affect its operation as part
> of it's description.  It doesn't need to explain them, just reference them
> and even if it only had some of the more key and frequently used ones it
> would be a start.
>
> I have run into this issue time and again: the documentation doesn't
> really support discovery of new things that SCons can do.  In the end I
> often end up scanning the Tools directory and reading the code and trying
> to figure out SCons is doing to understand what I need to do.
>
> Having watched this list for quite a while, I've seen a number of cases
> where questioners have been told rather curtly to read the documentation.
> Maybe this is the reason the questioners have come to the list; that they
> have struggled to find the information they seek in the documentation due
> to the way it's presented.
>
> Dominic
>
>
>
> On 05/08/2015 19:32, Dirk Bächle wrote:
>
>> Hi Viktor,
>> hi Dominic,
>>
>> please, as others have already requested, provide an example showing how
>> you call the Program Builder. Ideally, it would be a self-contained MWE
>> in the form of an archive (SConstruct + sources, as *.TGZ for example)
>> which demonstrates the problem that you experience.
>>
>> @Dominic: The original post doesn't mention start-group/end-group at
>> all, so I don't understand why you refer to the according passage in the
>> GCC specs when claiming that it's a bug indeed.
>>
>> @Viktor: The default definition of the LINKCOM variable is
>>
>>    $LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS
>>
>> , so the question has to be raised how you get the source "test.o" to
>> appear last in your command line. Are you sure that you're *not* simply
>> adding the required "-L... -l..." flags to LINKFLAGS directly, but are
>> using LIBS and LIBPATH as you're supposed to do (see also the UserGuide,
>> Appendix A "Construction Variables")?
>>
>> Best regards,
>>
>> Dirk
>>
>> On 05.08.2015 16:40, Viktor Dick wrote:
>>
>>>
>>> Hi,
>>> I just now noticed that on ubuntu 14.04, the linker seems to have
>>> problems with the way it is called by scons. In particular,
>>>
>>> g++ -o test test.o -L/usr/lib/x86_64-linux-gnu -lboost_system
>>>
>>> works while
>>>
>>> g++ -o test -L /usr/lib/x86_64-linux-gnu -lboost_system test.o
>>>
>>> throws linker errors. Unfortunately, the second way is the one that is
>>> chosen by SCons by default when using the Program() builder.
>>>
>>> Is there a quick fix to tell scons to change the order of the parameters
>>> or do I have to write a complete builder for this?
>>>
>>> Regards,
>>> Viktor
>>>
>>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150805/9afb7e95/attachment-0001.html>


More information about the Scons-users mailing list