使用 cl.exe 进行命令行编译?

Command line compile using cl.exe?(使用 cl.exe 进行命令行编译?)

本文介绍了使用 cl.exe 进行命令行编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在不使用 IDE 的情况下使用 Visual Studio Express 2010 C++ 编译器.我在 C:Program Files (x86)Microsoft Visual Studio 10.0VCin 中找到了 cl.exe.但是我有一些困难.首先,当我输入 cl 说程序无法启动,因为您的计算机中缺少 mspdb100.dll"时,它给了我一个警告弹出窗口.

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.0VCin. 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.'

所以我将 C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDE 添加到系统路径,然后再试一次,但这次:

So i add C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDE to the system path and then try again, but this time:

致命错误 C1510:无法加载语言资源 clui.dll.

fatal error C1510: Cannot load language resource clui.dll.

知道如何解决这个问题以便我可以编译吗?另外,我将如何设置路径,以便我可以从不包含 cl.exe 的解决方案文件夹中键入cl main.cpp"等.目前我必须在 bin 文件夹内.谢谢.

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.

推荐答案

尝试从

Start->
    All Programs ->
        Microsoft Visual Studio 2010 ->
            Visual Studio Tools ->
                Visual Studio Command Prompt 2010

或者,您可以通过在命令提示符下运行来设置环境:

Alternatively, you can set up the environment by running this in a command prompt:

"c:Program Files (x86)Microsoft Visual Studio 10.0VCvcvarsall.bat" x86

(注意:这将在运行后保留您的环境设置.)

(note: this will leave your environment set up after running.)

(注意2:根据需要更改x86.选项为x86ia64amd64x86_amd64, x86_ia64)

(note2: change x86 as desired. options are x86, ia64, amd64, x86_amd64, x86_ia64)

从那里您可以运行 cl.exe.如果您希望在运行 cl 时自动完成和撤消此操作,请创建一个包含以下内容的批处理文件:

From there you can run cl.exe. If you want this to be automatically done and undone whenever you run cl, create a batch file with this content:

@echo off
%comspec% /c ""c:Program Files (x86)Microsoft Visual Studio 10.0VCvcvarsall.bat" x86 && cl.exe %*"

(/c 告诉命令提示符在运行此命令后结束会话,以便您的环境恢复正常.)

(the /c tells the command prompt to end the session after running this command, so your environment returns to normal.)

从那里,将其命名为 cl.bat.将其放在某个文件夹中,并将该文件夹的路径添加到您的 PATH 环境变量中,确保它位于 cl.exe 的路径之前code>,以便在您键入 cl 而不是 cl.exe

From there, name it cl.bat. Put this in a folder somewhere, and add the path to that folder to your PATH environment variable, making sure it comes before the path to cl.exe, so that this cl.bat is executed whenever you type cl instead of cl.exe

我建议你把 cl.bat 放在你的 system32/ 文件夹中,它应该放在 cl.exe 的路径之前默认安装.

I recommend you just put cl.bat in your system32/ folder, it should come before cl.exe's path on a default installation.

或者,您可以按任何顺序添加它并始终键入 cl.bat,或将其命名为其他名称,以免混淆.

Alternatively, you can add it in any order and always type cl.bat, or name it something else so there's no confusion.

这篇关于使用 cl.exe 进行命令行编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 cl.exe 进行命令行编译?

基础教程推荐