By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,676 Members | 2,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,676 IT Pros & Developers. It's quick & easy.

help in simplification of code [string manipulation]

P: n/a

How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut',
'GLU',
'GL',
'm',]
Thanks,
--j

Sep 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
John wrote:
How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut',
'GLU',
'GL',
'm',]

LDFLAGS = '-lglut -lGLU -lGL -lm'
libs = [flag[2:] for flag in LDFLAGS.split()]
libs

['glut', 'GLU', 'GL', 'm']

Kent
Sep 13 '05 #2

P: n/a
John a écrit :
How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut',
'GLU',
'GL',
'm',]
Thanks,
--j


Why don't you use the LIBS var in the environment instead of the LDFLAGS
? And what use would be the libs var for you ?

if sys.platform[:5] == 'linux':
libs = ['glut',
'GLU',
'GL',
'm',]
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LIBS = Split(libs))
env.Append(CPPPATH=['include', 'include/trackball'])
Sep 13 '05 #3

P: n/a

Thanks for your replies...
Solved my problem.
--j

Christophe wrote:
John a écrit :
How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut',
'GLU',
'GL',
'm',]
Thanks,
--j


Why don't you use the LIBS var in the environment instead of the LDFLAGS
? And what use would be the libs var for you ?

if sys.platform[:5] == 'linux':
libs = ['glut',
'GLU',
'GL',
'm',]
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LIBS = Split(libs))
env.Append(CPPPATH=['include', 'include/trackball'])


Sep 13 '05 #4

P: n/a
John a écrit :
Thanks for your replies...
Solved my problem.
Even so, I made a big mistake here. The Split function is of no use
because there is already a list of flags. Better do it like that :
libs = Split('glut GLU GL m')
env.Append (LIBS = libs)

BTW, Split is a scons function.
Christophe wrote:
John a écrit :
How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut',
'GLU',
'GL',
'm',]
Thanks,
--j


Why don't you use the LIBS var in the environment instead of the LDFLAGS
? And what use would be the libs var for you ?

if sys.platform[:5] == 'linux':
libs = ['glut',
'GLU',
'GL',
'm',]
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LIBS = Split(libs))
env.Append(CPPPATH=['include', 'include/trackball'])


Sep 14 '05 #5

P: n/a

But ur previous solution worked on my machine...
although a friend tried it on his machine and the libraries
were not found even if they existed! (Even the -lm was not found)

Can you explain a bit why the previous solution worked?

Thanks for ur help,
--j

Sep 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.