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

Dominic Binks dominic.binks at thebinkles.net
Wed Aug 5 15:06:31 EDT 2015


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


More information about the Scons-users mailing list