Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to run cpp file using scons

Tags:

c++

scons

i am trying to compile a c++ program in scons. the scons works fine for c program but for c++ its giving the following error. please can anybody help me about this, who knows about this?

first.cpp

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

SConstructor

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

the error:

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.

what could be the problem in this?

like image 232
suma Avatar asked Dec 12 '25 20:12

suma


1 Answers

You dont have a compiler for C++ installed, or at least SCons cant find it. Although you would expect SCons to explicitly tell you it cant find the compiler, I think what actually happens is it has a Construction Variable for the compiler that is actually empty, and it uses that to create the command line.

If you do indeed have it installed, you can fix this problem as follows:

env = Environment()
env.Replace(CXX = "/path/to/the/c++/compiler")
like image 79
Brady Avatar answered Dec 14 '25 11:12

Brady



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!