Share via


How to set environment variables for MSVC++ cl.exe compiler alongside older versions?

Question

Tuesday, December 17, 2019 5:23 PM

Hello I've installed MSVC++ 6.0 in my computer so it has set the environment variables.

No I've installed MSVC++ 2019 but when I go to Computer properties->advanced system settings->Environment variables

Include contains only C:\Program Files (x86)\Microsoft Visual Studio\VC98\atl\include;C:\Program Files (x86)\Microsoft Visual Studio\VC98\mfc\include;C:\Program Files (x86)\Microsoft Visual Studio\VC98\include

and the remaining path, libs... all contains folders of MSVC++6 but not 2019.

  • I need this because sometimes I want to compile my C++20 code from CMD not from IDE.

  • I've run as administrator VsDevCmd.bat but it didn't make changes!

  • So how can I set the environment variables for visual Studio 2019? Thank you!

All replies (3)

Wednesday, December 18, 2019 12:04 AM

If you have installed Visual Studio correctly then there will be one of two options available.

1) Links in start

The various command prompts that state a platform will set up an environment for Visual Studio 2019. The x64 Native Tools Command Prompt will set up the environment so that it runs the x64 hosted compiler that targets 64 bit Windows. The x86 Native Tools Command Prompt will set up the environment so that it runs the x86 hosted compiler that targets 32 bit Windows. The x64_x86 Cross Tools Command Prompt will run the x64 hosted compiler that targets 32 bit Windows and the x86_x64 Cross Tools Command Prompt will run the x86 hosted compiler that targets 64 bit Windows.

2) You use the Visual C++ batch files:

If you notice these are located in a completely different location to the developer command prompt batch file. The files will set up the same environments as mentioned above. These also don't need to be run as administrator.

This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.


Wednesday, December 18, 2019 2:04 AM

Hi Hana_bchna,

Welcome to MSDN forum.

For your requirement, you could find cl.exe under this path: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin".

For example, we could add x64 cl.exe into environment variable manually:

Any feedback will be greatly appreciated.

Best Regards,

Dylan

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


Monday, December 30, 2019 10:05 AM

Hi Hana_bchna,

Did your issue still persists? If you want to compile the files in the Developer Command Prompt for VS2019 and all the compilers are already  configured in that mode. You can just use it directly. If your issue still persists, please feel free to let us know. 

Best Regards,

Perry

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com