-1

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!

Jay Shin
  • 914
  • 1
  • 7
  • 12
  • This one might be related http://stackoverflow.com/questions/4403253/how-to-run-g-from-a-terminal-window-on-my-mac . – dirkbaechle Apr 21 '16 at 17:14
  • @dirkbaechle I don't know how to add the Unix Development Support in XCode 7.3 – Jay Shin Apr 22 '16 at 10:01
  • The given link explains how to do this. Which steps did you try, and what kind of error messages did you encounter? If you can answer these two, please use them to open a new question on SO when hitting new problems that you can't seem to overcome, after seriously trying...I'm not a MAC user, so I can't help you out any further, I guess. – dirkbaechle Apr 22 '16 at 12:39
  • @dirkbaechle the given link is talking about XCode 4.3 which has really different configurations. I did try and I am not a Mac User either so before denouncing me for not trying maybe you should comment on something you know about. Unfortunately, your answer wasn't helpful as my problem is regarding trailing slashes, not XCode versions, but thanks for trying. – Jay Shin Apr 22 '16 at 13:28
  • You should add updates about what you've tried to fix this issue to this question instead of opening a duplicate. I think @dirkbaechle was recommending opening a new question if you hit a problem that is significantly different from the posted question. – Dave Bacher Apr 22 '16 at 16:08

1 Answers1

2

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.

Dave Bacher
  • 15,652
  • 3
  • 63
  • 86
  • You know what? I just figured that out a few minutes ago, and I don't know why this is happening either! But yes thanks so much for your reply. It gave me second confirmation that I am not the only one who have suffered from this problem and had to hack their way. – Jay Shin Apr 22 '16 at 16:11