I've been struggling with the most minor issue I've ever dealt with while working with SCons, but this trivialness seems to not go away that easily as the issue itself is.
So here's the situation.
I have a project that compiles perfectly when I just append a single forward slash at the end of a libpath in one of the system libraries of XCode.
When I give that to SCons, it some how strips that slash out and invokes a g++ -out without that slash.
When I manually use the g++ command it invokes with the slash, it works.
The following are the code snippets to help your understanding.
This is the code that appends the library:
env.AppendUnique(LIBPATH = [r'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/lib/system/'])
As you can see I have a slash behind 'usr/lib/system'.
And here is the g++ command invoked by SCons:
g++ -o output.dylib stuff.os -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/lib/system -otherstuff...
As you can see, the slash is tripped off at the end.
So if I do this:
g++ -o output.dylib stuff.os -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/lib/system/ -otherstuff...
Everything works perfectly.
Any ideas on how to fix this stupid problem of a stupid newbie?
Many thanks to you guys in advance!
As you've noticed, SCons does some interpretation on the library paths when constructing the link command. You can work around this by providing the flags to the link command directly through the LINKFLAGS
environment variable, bypassing LIBPATH
for the paths that are causing problems.
This makes your SConstruct somewhat less portable because you have to specify the command line options yourself.
SConstruct:
# SConstruct
libdir1 = '/Users/dave/lib1/'
libdir2 = '/Users/dave/lib2/'
env = Environment(LIBPATH = libdir1, LINKFLAGS = ['-L' + libdir2])
program = env.Program('test', 'test.c')
Generates the following output:
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test.o -c test.c
gcc -o test -L/Users/dave/lib2/ test.o -L/Users/dave/lib1
scons: done building targets.
Notice that the trailing space on lib2 is preserved.
It's not clear to me why this error is happening and the root cause deserves further investigation.