使用 cl.exe 进行命令行编译?
我尝试使用 Visual Studio Express 2010 C++ 编译器而不使用 IDE。我在 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin 中找到了 cl.exe。然而我有一些困难。首先,当我输入 cl 时,它会弹出一个警告,提示“程序无法启动,因为您的计算机中缺少 mspdb100.dll”。
所以我将 C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE 添加到系统路径,然后重试,但这一次:
致命错误 C1510:无法加载语言资源 clui.dll。
知道如何解决这个问题以便我可以编译吗?另外,我将如何设置路径,以便我可以从不包含 cl.exe 的解决方案文件夹中键入“cl main.cpp”等。目前我必须位于 bin 文件夹内。谢谢。
Am trying to use the Visual Studio Express 2010 C++ compiler without using the IDE. I found cl.exe in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin. However am having a few difficulties. Firstly it gave me a warning pop up when i type cl saying 'Program cannot start because mspdb100.dll is missing from your computer.'
So i add C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE to the system path and then try again, but this time:
fatal error C1510: Cannot load language resource clui.dll.
Any idea how to solve this so i can compile? Also how would i set up the path so i can just type 'cl main.cpp' etc, from within a solution folder that does not contain cl.exe. At the moment i have to be inside bin folder. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试从以下位置启动 Visual Studio 命令提示符
或者,您可以通过在命令提示符中运行此命令来设置环境:(
注意:这将在运行后保留您的环境设置。)
(注意 2:更改
x86
根据需要,选项有x86
、ia64
、amd64
、x86_amd64
、x86_ia64
)从那里您可以运行
cl.exe
。如果您希望每次运行cl
时自动完成和撤消此操作,请创建一个包含以下内容的批处理文件:(/c
告诉命令提示符在运行此命令,以便您的环境恢复正常。)然后将其命名为
cl.bat
。将其放在某个文件夹中,并将该文件夹的路径添加到您的PATH
环境变量中,确保它位于cl.exe 的路径之前。 code>,以便每当您键入
cl
而不是cl.exe
时都会执行此cl.bat
我建议您只输入
cl .bat
在您的system32/
文件夹中,它应该出现默认安装时cl.exe
路径之前。或者,您可以按任意顺序添加它并始终键入
cl.bat
,或者将其命名为其他名称,这样就不会造成混淆。Try starting the Visual Studio Command Prompt from
Alternatively, you can set up the environment by running this in a command prompt:
(note: this will leave your environment set up after running.)
(note2: change
x86
as desired. options arex86
,ia64
,amd64
,x86_amd64
,x86_ia64
)From there you can run
cl.exe
. If you want this to be automatically done and undone whenever you runcl
, create a batch file with this content:(the
/c
tells the command prompt to end the session after running this command, so your environment returns to normal.)From there, name it
cl.bat
. Put this in a folder somewhere, and add the path to that folder to yourPATH
environment variable, making sure it comes before the path tocl.exe
, so that thiscl.bat
is executed whenever you typecl
instead ofcl.exe
I recommend you just put
cl.bat
in yoursystem32/
folder, it should come beforecl.exe
's path on a default installation.Alternatively, you can add it in any order and always type
cl.bat
, or name it something else so there's no confusion.只需按照 jsvk 建议使用
vcvarsall.bat
即可:之后,如果您可以避免很多头痛,请使用
devenv.exe
来构建您的东西:有您可以使用 devenv /? 来检查许多其他命令行开关。
Just use
vcvarsall.bat
as jsvk suggested:After that, use
devenv.exe
to build your stuff if you keep yourself safe from a lot of head-aches:There are a lot of other command line switches which you can check with
devenv /?
.这是一项非常简单且艰巨的任务。首先将编译器路径添加到系统路径:C:\Program Files\Microsoft Visual Studio 10.0\VC\bin;接下来,打开命令提示符并将目录更改为源文件夹;然后执行vcvars32.bat文件,设置在x86上使用vc++的环境;之后,您现在可以输入 cl 来编译您的程序
This is a quite simple and strait forward task. Firstly add the compiler path to system path.:C:\Program Files\Microsoft Visual Studio 10.0\VC\bin; Next, open command prompt and change directory to your source folder; Then execute the vcvars32.bat file to setup the environment for using vc++ on x86; After this, you can now type cl to compile your program
我安装了多个版本的VS;我为每个版本创建一个小 .BAT 文件,放置在路径中的某个位置,调用相关的“vcvarsall.bat”。例如,“vc9.bat”对于 VS2008 调用 vcvarsall.bat,而“vc10.bat”对于 VS2010 调用 vcvarsall.bat。我可以像往常一样打开一个普通的命令窗口,输入“vc9”,然后,该命令窗口已准备好使用 VS2008 进行编译等。
I have multiple versions of VS installed; I create a little .BAT file for each version, placed somewhere in the path, that calls the relevant "vcvarsall.bat". e.g. "vc9.bat" calls vcvarsall.bat for VS2008, while "vc10.bat" calls vcvarsall.bat for VS2010. I can open a normal command window as usual, type "vc9", and presto, that command window is ready to compile etc using VS2008.
当链接器内存不足时会发生该错误。
您可以使用 x64 工具架构 Visual studio 工具。
msbuild 命令行:
或者,更好的是,将其添加到 .vcxproj 中的项目设置中。
要指定编译器和工具的 64 位版本,请将以下属性组元素添加到 Myproject.vcxproj 项目文件中的 Microsoft.Cpp.default.props 元素之后:
这些选项将使 Visual studio 使用 amd64 架构下的工具文件夹(根据目标架构):
VC\bin\amd64
VC\bin\amd64_x86
VC\bin\amd64_arm
https://msdn.microsoft.com/en-us /library/dd293607.aspx
That errors occurs when the linker runs out of memory.
You can use the x64 tool architecture Visual studio tools.
msbuild command line:
Or, better yet, add it to the project's settings in the .vcxproj.
To specify the 64-bit version of the compiler and tools, add the following property group element to the Myproject.vcxproj project file after the Microsoft.Cpp.default.props element:
These options will make Visual studio use the tools under the amd64 architecture folders (according to the target architecture):
VC\bin\amd64
VC\bin\amd64_x86
VC\bin\amd64_arm
https://msdn.microsoft.com/en-us/library/dd293607.aspx