如何使用MinGW在命令行上编译C程序? [英] How to compile C program on command line using MinGW?

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

问题描述

在Windows 7的命令行中输入什么命令来编译一个基本的C程序?



就像我在字面上想知道你在命令中输入什么提示,编译一个.c文件。



我试过了:

 > gcc foo.c 

但它表示:

 'gcc'不被识别为内部或外部命令,
可操作程序或批处理文件。

我也试过:

 > minGW foo.c 

但我回来了:

 'minGW'不被识别为内部或外部命令,
可操作程序或批处理文件。

我有一个路径环境变量设置为MinGW的安装位置:

  C:\程序文件(x86)\CodeBlocks\MinGW\bin 

我无法找到任何有关我要出错的信息,并且在官方的MinGW文档中找不到任何信息,因为它看起来像这样简单,这是一个令人尴尬的问题,它让人想知道该怎么办? 它表示找不到 gcc.exe


我将路径环境变量设置为MinGW的安装位置


也许您没有正确设置路径?

  echo%path%

显示gcc.exe的路径?否则,编译类似于Unix:

  gcc filename.c -o文件名


What command does one have to enter at the command line in Windows 7 to compile a basic C program?

Like I am literally wondering what you type in the command prompt, to compile a .c file.

I tried:

> gcc foo.c

But it says:

'gcc' is not recognized as an internal or external command, 
 operable program or batch file.

I also tried:

> minGW foo.c

But I got back:

 'minGW' is not recognized as an internal or external command, 
  operable program or batch file.

I have a path environment variable set to where MinGW is installed:

C:\Program Files (x86)\CodeBlocks\MinGW\bin

I can't really find any information on where I'm going wrong, and can't find anything in the official MinGW documentation, as it seems like this is something so simple, sort of an embarrassing question, that it's figured people know what to do?

解决方案

It indicates it couldn't find gcc.exe.

I have a path environment variable set to where MinGW is installed

Maybe you haven't set the path correctly?

echo %path%

shows the path to gcc.exe? Otherwise, compilation is similar to Unix:

gcc filename.c -o filename

这篇关于如何使用MinGW在命令行上编译C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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