无法使用scons运行cpp文件

问题描述:

我正在尝试编译scons中的C++程序。 scons适用于c程序,但对于C++,它给出了以下错误。 请有人可以帮我解释一下,谁知道这件事?无法使用scons运行cpp文件

first.cpp

#include <iostream> 
int main() 
{ 
    std::cout << "hellooo" << std::endl; 
    return 0; 
} 

SConstructor

Program('first','first.cpp') 

错误:

scons: Reading SConscript files ... 
scons: done reading SConscript files. 
scons: Building targets ... 
o first.o -c first.cpp 
sh: o: command not found 
o first.exe first.o 
sh: o: command not found 
scons: done building targets. 

这可能是这个问题?

您没有安装C++的编译器,或者至少SCons无法找到它。虽然你会希望SCons明确地告诉你它找不到编译器,但我认为实际发生的是它有一个编译器的结构变量,它实际上是空的,并且它使用它来创建命令行。

如果您确实安装了它,你可以按如下解决这个问题:

env = Environment() 
env.Replace(CXX = "/path/to/the/c++/compiler")