Handmade Hero » Forums » Code » cl doesn't work in VS 2017 even if it says the environment is initialized
EvulStd
3 posts
#12735 cl doesn't work in VS 2017 even if it says the environment is initialized
2 weeks ago

Hi, I was using the visual studio 2015(which was working perfectly fine), then when I switched to visual studio 2017, this happened.

w:\handmade\misc>shell
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.16
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

w:\handmade\misc>cl
'cl'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.//This means it cannot run cl in korean

Although it says that the environment is initialized, cl command still does not work. What should I do?
mmozeiko
Mārtiņš Možeiko
1437 posts
1 project
#12736 cl doesn't work in VS 2017 even if it says the environment is initialized
2 weeks ago

Are you sure you have installed C++ support in Visual Studio 2017? I believe it needs to be explicitly selected in installer.

Can you show PATH after you have called shell?

EvulStd
3 posts
#12737 cl doesn't work in VS 2017 even if it says the environment is initialized
2 weeks ago Edited by EvulStd on Aug. 3, 2017, 5:55 p.m.

Thank you very much for replying!

I don't quite understand your meaning - 'path after you have called shell'

This is my shell.bat

@echo off
call "D:\VisualStudio2017\VC\Auxiliary\Build\vcvarsall.bat" x64
set path=w:\handmade\misc; %path%

Also, I installed these functions in Visual Studio 2017
(the name might be slightly different as I am using Korean)
1.Desktop Development using c++
2.Game Development using c++

With these features, I can currently make a empty console project in Visual Studio 2017 and compile this code.

#include <stdio.h>

int main(void)
{
return 0;
}
mmozeiko
Mārtiņš Možeiko
1437 posts
1 project
#12738 cl doesn't work in VS 2017 even if it says the environment is initialized
2 weeks ago Edited by Mārtiņš Možeiko on Aug. 3, 2017, 6:13 p.m.

I was asking to execute "PATH" command and show the output.

From the code you posted it looks like you have extra space here:
1
2
3
set path=w:\handmade\misc; %path%
                          ^
                          | here

Assuming "vcvarsall.bat" file set path to cl location as first item in list, this space will be prepended to folder location. Basically path afterwards will contain:
1. "w:\handmade\misc"
2. " c:\location\to\folder\where\is\cl.exe"
3. ... other items.

This will make cl.exe to not be found, because it will look for " c:\location\to\folder\where\is\cl.exe" location which does not exist.

Remove the space.

And next time please remember to post code in [ code ] bbtags so it is easier to read.

EvulStd
3 posts
#12739 cl doesn't work in VS 2017 even if it says the environment is initialized
2 weeks ago

It worked! Thank you so much.

I'll make sure to use tags from now on, too.
Again, thank you!