Search code examples
visual-studioenvironment-variablesnmakecl

Visual Studio scripts don't set up environment variables correctly


I run the following command to setup my environment:

PS C:\WINDOWS\system32> vcvarsall.bat x86_amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.8.5
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86_x64'

I have a file test.cpp containing just one line: #include <type_traits> as shown here:

PS C:\Users\me\Documents\env-setup> cat .\test.cpp
#include <type_traits>

When I run the following I get errors:

PS C:\Users\me\Documents\env-setup> cl -c test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26730 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
test.cpp(1): fatal error C1034: type_traits: no include path set

Can anybody give me a hint why vcvarsall.bat is not setting up my environment variables correctly. I also have tried vcvars64.bat, vcvars32.bat and others with no luck!


Solution

  • As @RetiredNinja commented, I was running the commands on PowerShell. The problem is resolved by using a command prompt!