cl error 0xc000007b when invoked from scons script


I am trying to compile a simple program using scons + MSVC compiler under Windows. Program source is just simple "Hello world".

#include <iostream>

using namespace std;

int main() {
  cout << "Hello World!\n";
  return 0;

SConstruct is utterly simple:


When I run scons in the source directory, I get

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fohw.obj /c /TP /nologo
scons: *** [hw.obj] Error 123
scons: building terminated because of errors.

in the console and pop-up message with 0xc000007b error.

Aslo results of where command:

where cl
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\Hostx86\x86\cl.exe
where scons

I don't have any clue what's wrong.

UPD SCons debug output


Error window when I run scons

asked on Stack Overflow Feb 17, 2018 by Montreal • edited Feb 23, 2018 by Montreal

1 Answer


After some experiments with cl and scons I have finally figured out what was wrong and how to fix it.

First of all, cl should be available from the command line. If after entering command cl in the console you get errors like command not found, you should add path to cl.exe to the PATH system variable. In my case


After this you should set up variables INCLUDE and LIB to tell compiler and linker where to find include files and libs. And this part is a little bit tricky, because, to my surprise, cl does not compiling anything without Windows Kits 10 (whatever it is). Thus, you should specify its includes and libs accordingly. In my case

INCLUDE=C:\Microsoft\VC\Tools\MSVC\14.14.26428\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt
LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\ucrt\x86;C:\Microsoft\VC\Tools\MSVC\14.14.26428\lib\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x86

When these variables are set up correctly, should compile fine.

And, probably, this should do the trick for scons too, but to make one hundred percent sure it works correctly, SConstruct should be modified to something like this

import os

env = Environment(ENV = os.environ)
flags = ["/EHsc"] # Flags are completely optional
env.Program("", CXXFLAGS=flags)

With all these steps, everything should compile fine.

answered on Stack Overflow Jun 23, 2018 by Montreal

User contributions licensed under CC BY-SA 3.0