[Scons-users] How to force flags order when linking static libraries
    Davide Coppola 
    vivaladav at gmail.com
       
    Tue Mar 11 12:10:31 EDT 2014
    
    
  
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.
This is the final command generated by Scons:
g++ -o bin/debug/game/bof -lSDL2 -lpthread -Wl,--no-undefined -lm -ldl -lts
-lpthread -lrt build/debug/game/tmp_src/main.o -Lbuild/debug/libs/SDL2
-Lsrc/libs/SDL2 -lSDL2
which raises a lot of errors like
build/debug/libs/SDL2/libSDL2.a(SDL_dynapi.o): In function
`get_sdlapi_entry':
SDL_dynapi.c:(.text+0xc76c): undefined reference to `dlopen'
SDL_dynapi.c:(.text+0xc78a): undefined reference to `dlsym'
...
build/debug/libs/SDL2/libSDL2.a(SDL_sysmutex.o): In function
`SDL_CreateMutex_REAL':
SDL_sysmutex.c:(.text+0x39): undefined reference to `pthread_mutexattr_init'
SDL_sysmutex.c:(.text+0x4a): undefined reference to
`pthread_mutexattr_settype'
....
whereas running g++ with the following parameters succeed:
g++ -o bin/debug/game/bof build/debug/game/tmp_src/main.o
-Lbuild/debug/libs/SDL2 -Lsrc/libs/SDL2 -lSDL2 -lpthread -Wl,--no-undefined
-lm -ldl -lts -lpthread -lrt
I understand the problem is the order the libraries are linked against the
executable, but I can't find a way to force such order in Scons.
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?
-- 
Davide Coppola
*website:* http://www.davidecoppola.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140311/3e42980a/attachment.htm 
    
    
More information about the Scons-users
mailing list