Search code examples
scons

How do I troubleshoot CheckLib returning false?


Scons version is 2.3.3. Here is the relevant portion of the build script:

if not conf.CheckLib('portaudio'):
    raise Exception(
        'Did not find libportaudio.a, portaudio.lib, or the PortAudio-v19 development header files.')

CheckLib is always returning a false value. How do I debug this? I followed it through the Scons source code until it tries to build a small test program but then I could not track it any further.

I tried all the troubleshooting flags suggested in section 27 of the Scons manual but none of them produce any additional output. For example,

C:\code\github\mixxx2>scons -Q --debug=findlibs winlib=%WINLIB_PATH% qtdir=%WINL
IB_PATH%\build\qt-everywhere-opensource-src-4.8.6 hss1394=1 mediafoundation=1 op
us=0 build=%BUILD_TYPE% machine=%TARGET_MACHINE% toolchain=msvs virtualize=0 tes
t=1 sqlitedll=0 mssdk_dir=%MSSDK_DIR% force32=1

I don't know what the -Q option is for. I have tried omitting it and it makes no difference; I get no additional information on stdout. Just this:

[...truncated...]
Checking for C library portaudio... no
ERROR:root:Unmet dependency: Did not find libportaudio.a, portaudio.lib, or the
PortAudio-v19 development header files.

Solution

  • The Configure object generates a log file as it is performing its actions, by default the file is config.log. According to the Configure Contexts section of the scons man page, the log file can be customized when the Configure object is initialized by passing a log_file argument.

    With a simple SConstruct, I get a config.log file with the build failure.

    SConstruct:

    env = Environment()
    conf = Configure(env)    
    if not conf.CheckLib('foo'):
        Exit('Can not find foo')
    

    config.log:

    file /home/dbacher/Code/scons-test/SConstruct,line 2:
            Configure(confdir = .sconf_temp)
    scons: Configure: Checking for C library foo... 
    .sconf_temp/conftest_0.c <-
      |
      |
      |
      |int
      |main() {
      |  
      |return 0;
      |}
      |
    gcc -o .sconf_temp/conftest_0.o -c .sconf_temp/conftest_0.c
    gcc -o .sconf_temp/conftest_0 .sconf_temp/conftest_0.o -lfoo
    /usr/bin/ld: cannot find -lfoo
    collect2: ld returned 1 exit status
    scons: Configure: no
    

    I would guess this log file is enough for you to diagnose the problem.

    BTW, the scons manual describes the -Q option as:

    Quiets SCons status messages about reading SConscript files, building targets and entering directories. Commands that are executed to rebuild target files are still printed.