在 Windows 中从命令提示符编译 C 代码? [英] Compiling C-code from the Command Prompt in Windows?

查看:20
本文介绍了在 Windows 中从命令提示符编译 C 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 Windows 中的命令提示符编译 C 代码.我已将环境变量添加到 PATH,并且可以使用以下命令编译 .cs 文件:csc app.cs

I want to compile C code from the Command Prompt in Windows. I have added the environment variable to the PATH and I can compile .cs files with: csc app.cs

没关系,但是我该如何编译 app.c?

That's OK, but how do I compile app.c?

推荐答案

你这样做:

cl app.c

这是一个完整的抄本,包括为 Visual Studio 2005 设置环境(对于 Visual Studio 2008,将8"更改为9.0").

Here's a complete transcript, including setting up the environment for Visual Studio 2005 (change "8" to "9.0" for Visual Studio 2008).

C:src	ests>"Program Files (x86)Microsoft Visual Studio 8vcinvcvars32.bat"
Setting environment for using Microsoft Visual Studio 2005 x86 tools.

C:src	ests>type app.c
#include <stdio.h>
int main(void)
{
    printf("Hello world!
");
    return 0;
}

C:src	ests>cl app.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86

Copyright (C) Microsoft Corporation.  All rights reserved.

app.c
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:app.exe
app.obj

C:src	ests>app
Hello world!

这篇关于在 Windows 中从命令提示符编译 C 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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