在Visual C ++中在命令行上编译 [英] Compiling on the command line in Visual C++

查看:106
本文介绍了在Visual C ++中在命令行上编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何使用Visual C ++中的命令行编译器('cl'和'link')来构建项目?我们更习惯在这里使用'make'和'gcc',但最近被移到Visual Studio。我想我们可以使用nmake,但我希望一些关于使用'cl'和'链接'的信息(如在编译没有.sln文件)。

Does anyone know how to use the command line compiler ('cl' and 'link') in Visual C++ to build a project? We are more used to 'make' and 'gcc' here, but were recently moved to Visual Studio. I suppose we could use nmake, but I'm hoping for some information regarding using 'cl' and 'link' (as in compiling without a .sln file).


  1. 创建对象文件

  2. 链接对象文件以创建可执行文件

是我们想要的,但我似乎不能使用命令行参数。帮助?

is what we want, but I just can't seem to make it work using the command line parameters. Help please?

推荐答案

编辑:对不起,没有注意到without .sln 。请忽略这个答案。我把它留给其他人,可能实际需要这个,但它不是对原始问题的回答。

Edit: sorry, didn't notice the 'without .sln' part. Ignore this answer please. I'm leaving it in place for others that may actually need this but it's not an answer to the original question.

如果你只是想构建一个解决方案/项目文件(也就是说,你的大部分构建设置已经在项目文件中定义),你可以使用 devenv.exe 为你构建解决方案/项目 - 这可能是

If you just want to build a solution/project file (that is, most of your build settings are already defined in your project file), you can use devenv.exe to build the solution/project for you - this is probably the simplest way of doing a build from the command line.

例如:

devenv.exe myapp.sln /重建Release | x64

Release | x64 配置中构建 myapp.sln 解决方案。

cleans & builds the myapp.sln solution in the Release|x64 configuration.

如果您运行

devenv.exe /?

命令,它提供了所有命令行选项。您可以使用

command, it gives you all command-line options. You can use devenv to build only a specific project in the solution by using the `/project' switch.

使用 devenv 在解决方案中仅构建特定项目。如果你需要更多的灵活性(你愿意花很多时间编写正确的脚本),你可以使用 nmake 从命令行构建,但是不知道那么好,所以我不能给出有用的建议。

If you need more flexibility (and you're willing to spend a lot of time writing the right script), you can use nmake to build from the command-line, but I don't know that well, so I can't give useful advice.

这篇关于在Visual C ++中在命令行上编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆