[Scons-users] How to force flags order when linking static libraries
Dirk Bächle
tshortik at gmx.de
Tue Mar 11 14:23:17 EDT 2014
Hi Davide,
On 11.03.2014 17:10, Davide Coppola wrote:
> Hi,
>
> I'm trying to build a program which is linked against a static library
> (SDL2) built with Scons as well.
> The problem is that the final linking phase fails because of the order
> of the flags.
>
> [...]
>
> The SConsript to build the program is called by the following command:
>
> SConscript('src/game/SConscript', exports = 'env', variant_dir =
> 'build/' + env['mode'], src_dir = 'src', duplicate = 0)
>
> and it looks like this:
>
> Import('env')
>
> sources = Split(""" tmp_src/main.cpp """)
>
> env.Append(CPPPATH=['#/src/libs/SDL2/include'])
>
> env.Append(CCFLAGS = ['-D_REENTRANT'])
> env.Append(LINKFLAGS=['-lSDL2', '-lpthread', '-Wl,--no-undefined',
> '-lm', '-ldl', '-lts', '-lpthread', '-lrt'])
>
> env.Program('#/bin/%s/game/bof' % env['mode'], sources, LIBS =
> ['SDL2'], LIBPATH = ['../libs/SDL2'] )
>
>
> Any suggestion?
>
yes, you should use LINKFLAGS for specifying linker flags only, like the
"-Wl,--no-undefined". For the actual libraries there is the LIBS
variable instead. Its values get appended to the compiler command after
your object file, so this should solve your problem:
env.Append(LINKFLAGS=['-Wl,--no-undefined'])
env.Append(LIBS=['SDL2', 'pthread', 'm', 'dl', 'ts', 'pthread', 'rt'])
.
Best regards,
Dirk
More information about the Scons-users
mailing list