在命令提示符下运行C ++-Windows [英] Run C++ in command prompt - Windows
问题描述
我知道现在每个人都在使用IDE,但是我发现用notepad ++编写代码,使用命令提示符命令进行编译并从那里运行也更加简单。至少这适用于Java和Python。我试图弄清楚如何使用C ++做到这一点,但没有找到任何好的方法。有没有我可以坚持使用并使用 javac
和 java
要从CMD运行和编译我的代码?
I know that everyone uses an IDE nowadays, but I just find it simpler to write my code in notepad++, compile it using a command prompt command, and run it from there too. At least that works for Java and Python. I've tried to get my head around how to do that with C++, and haven't been able to find anything good. Is there any compiler (like Java's JDK) that I can stick into my path and use the C++ equivalent of javac
and java
to run and compile my code from CMD?
注意:请不要发布有关IDE更好的答案和评论-我知道它们是。我只是习惯用旧方法:D
Note: please don't post answers and comments about how IDEs are better - I know they are. I'm just used to doing it the old way :D
推荐答案
这取决于您使用的编译器。
It depends on what compiler you're using.
例如,如果您使用的是Visual C ++ .NET 2010 Express,请从开始菜单运行Visual C ++ 2010 Express命令提示符,然后可以简单地编译并运行代码。 / p>
For example, if you are using Visual C++ .NET 2010 Express, run Visual C++ 2010 Express Command Prompt from the start menu, and you can simply compile and run the code.
> cl /EHsc mycode.cpp
> mycode.exe
或从常规命令行运行 vcvars32。 bat
首先设置环境。或者搜索 setvcvars.cmd
(FLOSS项目的一部分),并使用它甚至找到已安装的VS并调用 vcvars32.bat
。
or from the regular command line, you can run vcvars32.bat
first to set up the environment. Alternatively search for setvcvars.cmd
(part of a FLOSS project) and use that to even locate the installed VS and have it call vcvars32.bat
for you.
请查看编译器手册中的命令行。
Please check your compiler's manual for command lines.
这篇关于在命令提示符下运行C ++-Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!