简体   繁体   中英

Calling CheckLib from SConscript file

I'm attempting to check for the existence of a library from inside my SConscript file, as follows:

# Not sure if this bit is relevant:
Import('env')
env = env.Clone()

# This is what I'm trying to do:
conf = env.Configure()
if conf.CheckLib('gcrypt'):
    pass # actually something more interesting

...but it's not working. All I'm getting is an opaque error from scons , as follows:

scons: ***
File "/home/src/foo/bar/SConscript", line 49, in <module>

...where line 49 is the conf = env.Configure() line.

This is on Mac OS X, where I don't expect to find the library mentioned. How do I detect this in my SConscript file?

I tested this and it worked just fine. Maybe its a problem with how you're creating or passing the env. Here is my sample code in case it helps:

SConstruct

env = Environment()
env.SConscript('SConscript', exports='env', duplicate=0)

SConscript

Import('env')

env = env.Clone()

conf = env.Configure()
if conf.CheckLib('gcrypt'):
  pass

And here is the result:

$ scons
scons: Reading SConscript files ...
Checking for C library gcrypt... no
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM