SCons-***未找到SConstruct文件

use*_*278 6 python scons

使用#cd scons-2.3.0#python setup.py install安装SCons

安装后,当我尝试运行scons时,得到以下错误.

scons:*找不到SConstruct文件.文件"/usr/local/lib/scons-2.3.0/SCons/Script/Main.py",第905行,在_main

如何克服这个???

Bra*_*ady 11

使用SCons时有3种方法可以指定SConstruct文件,如下所示:

  • scons从项目的根目录执行,其中应该有一个SConstruct文件.这是最标准的方式.

  • 从项目的子目录中,根目录中应该有一个SConsctruct文件,scons使用以下选项之一执行(如scons -h所示),告诉它查找SConstruct的目录结构

-u, --up, --search-up
Search up directory tree for SConstruct, build targets at or 
below current directory.

-U
Search up directory tree for SConstruct, build Default() targets 
from local SConscript.
Run Code Online (Sandbox Code Playgroud)
  • 明确指定SConstruct文件的位置,也可以从中获取 scons -h
-f FILE, --file=FILE, --makefile=FILE, --sconstruct=FILE
Read FILE as the top-level SConstruct file.
Run Code Online (Sandbox Code Playgroud)

以下是具有/home/notroot/projectDir以下目录结构的目录中的示例项目:

SConstruct
subdir/file.hh
subdir/file.cc
Run Code Online (Sandbox Code Playgroud)

以下是如何使用上面提到的不同选项:

选项1:

从根项目目录执行scons

# cd /home/notroot/projectDir
# scons
Run Code Online (Sandbox Code Playgroud)

选项2:

从项目目录中执行scons并告诉它查找SConstruct的dir层次结构

# cd /home/notroot/projectDir/subdir
# scons -u
Run Code Online (Sandbox Code Playgroud)

选项3:

从项目目录中执行scons并指定SConstruct的路径

# cd /home/notroot/projectDir/subdir
# scons -f /home/notroot/projectDir/SConstruct
Run Code Online (Sandbox Code Playgroud)