c++ - MSVC 环境变量未显示在不同的终端中

标签 c++ visual-studio-2010 windows-7-x64 haxe hxcpp

我正在使用 Haxe 的 HXCPP 生成 C++ 代码并使用 Microsoft Visual Studio 2010 Express Edition 对其进行编译。我正在关注 this指南,它会要求您运行 "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat" 以便 cl.exe (编译器)在您的构建路径中。

确实允许我运行 cl.exe,但仅限于该终端。如果我尝试从另一个终端或在我的 IDE (Sublime Text 2) 中运行它,它会失败。

我想出了一个解决方法:手动将变量值从终端复制并粘贴到 GUI 环境变量编辑器。

一定有更好的方法。我错过了什么?

构建.hxml

-main Test
-cpp bin

测试.hx

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

构建时的错误信息

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

最佳答案

您必须为您打开的每个终端(环境)运行以下命令:

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

它定义的环境变量都是本地的。

关于c++ - MSVC 环境变量未显示在不同的终端中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10254827/

相关文章:

c++ - OpenSSL HMAC 函数中的意外复杂性

visual-studio-2010 - 如何删除错误的 Visual Studio 模板?

c++ - printf 字符串输出 "Dz↕"getch() C++

windows-7 - Windows 7 是否支持 ITaskScheduler?

c++ - ptr 和 &ptr 的区别

c++ - 如何让选项卡控件接管 Qt Creator 中的整个窗口?

c++ - 适合在线嵌入的SVM库

c# - 在 Release 编译上启用代码

visual-studio-2010 - 错误 LNK2019 : unresolved external symbol MPI_INIT referenced in function

c++ - Windows SDK 7.1 64 位构建 CloseHandle 显然不在 kernel32.lib 中