MSVC environment variables not showing up in different terminals

1.3k Views Asked by At

I'm using Haxe's HXCPP to generate C++ code and compile it with Microsoft Visual Studio 2010 Express Edition. I'm following this guide and it asks you to run "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat" so that cl.exe (the compiler) is in your build path.

This does allow me to run cl.exe, but only in that terminal. It fails if I attempt to run it from another terminal or within my IDE (Sublime Text 2).

I figured out a workaround: manually copy+paste variable values from the terminal to the GUI environment variable editor.

There's gotta be a better way. What am I missing?

build.hxml

-main Test
-cpp bin

Test.hx

class Test {
    static function main() {
        trace("Hello World!");
    }
}

Error message when building

link.exe -out:Test.exe -nologo -machine:x86 -libpath:lib user32.lib -libpath:e:/VS8/PlatformSDK/Lib @all_objs
LINK : fatal error LNK1181: cannot open input file 'user32.lib'
Called from ? line 1
Called from BuildTool.hx line 1246
Called from BuildTool.hx line 554
Called from BuildTool.hx line 591
Called from BuildTool.hx line 710
Called from BuildTool.hx line 796
Called from BuildTool.hx line 285
1

There are 1 best solutions below

1
On

You must run the following command for each terminal (environment) that you have open:

c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat

The environment variables that it defines are all local.