Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用子目录中的includes生成Scons_C++_Scons - Fatal编程技术网

C++ 使用子目录中的includes生成Scons

C++ 使用子目录中的includes生成Scons,c++,scons,C++,Scons,您必须在sconstuct文件中编写什么代码,以便编译子目录中包含的所有类?目前,我的SConstruct文件如下所示: VariantDir('build', '.') env=Environment(CPPPATH=['#'], CPPDEFINES=[], LIBS=['-lpng', '-lassimp', '-lglfw3', '-lGLEW', '-lGLU', '-lGL', '-lX11', '-lXxf86vm',

您必须在sconstuct文件中编写什么代码,以便编译子目录中包含的所有类?目前,我的SConstruct文件如下所示:

VariantDir('build', '.')
env=Environment(CPPPATH=['#'],
                CPPDEFINES=[],
                LIBS=['-lpng', '-lassimp', '-lglfw3', '-lGLEW', '-lGLU', '-lGL', '-lX11', '-lXxf86vm', '-lXrandr', '-lpthread', '-lXi'],
                CXXFLAGS="-std=c++11")
env.Program(target='exec_test', source=[Glob('build/*.cpp')])
当我构建我的项目时,当调用子目录中的类中的方法时,我得到了对错误的
未定义引用。如果我将类移动到根目录,则不会出现错误

注意:在另一个目录中构建与此无关!我尝试在根目录中构建,但这并没有改变任何东西!:)

该函数不是递归函数,因此必须在源列表中添加每个子目录,如下所示:

env.Program(target='exec_test', source=[Glob('build/*.cpp'),
                                        Glob('build/subdir1/*.cpp',
                                        Glob('build/subdir2/*.cpp'])
<>这是可行的,或者您可以考虑创建一个层次结构,从而在每个子目录中创建一个Script脚本。