Visual Studio编译器如何指定构建cpp的包含路径 [英] visual studio compiler how to specify the include path to build cpp
问题描述
我正在使用批处理文件尝试使用 Visual Studio 的 cl.exe 构建我的 cpp 程序.这是它包含的内容:
I am using a batch file to try to build my cpp program using Visual Studio's cl.exe. This is what it contains:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe" /I "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\" "%1" /Fe "%1.exe"
我想让编译器从包含文件夹中包含 iostream 并将我的 .cpp (%1) 构建为 %1.exe.
I want to the compiler to include iostream from the include folder and build my .cpp (%1) as %1.exe.
相反,我得到:
Microsoft (R) C/C++ 优化编译器版本 17.00.60610.1 for x86版权所有 (C) 微软公司.保留所有权利.
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60610.1 for x86 Copyright (C) Microsoft Corporation. All rights reserved.
cl:命令行错误 D8003:缺少源文件名
cl : Command line error D8003 : missing source filename
我做错了什么?
Win8.1 x64
推荐答案
不要从标准命令提示符运行 cl.exe.使用随 VS 2015 一起安装的开发人员命令提示符".这会为您设置几个特定于您的安装的环境变量.
Do not run cl.exe from a standard command prompt. Use the "Developer Command Prompt" installed with VS 2015. This sets several environment variables for you, specific to your installation.
阅读更多:https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx
这篇关于Visual Studio编译器如何指定构建cpp的包含路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!