开源的c/c++编译器 mingm 编译、执行一段简单的c/c++代码
2015-08-22 09:21
537 查看
<pre name="code" class="html">MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications. MinGW provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs. (It does depend on a number of DLLs provided by Microsoft themselves, as components of the operating system; most notable among these is MSVCRT.DLL, the Microsoft C runtime library. Additionally, threaded applications must ship with a freely distributable thread support DLL, provided as part of MinGW itself). MinGW compilers provide access to the functionality of the Microsoft C runtime and some language-specific runtimes. MinGW, being Minimalist, does not, and never will, attempt to provide a POSIX runtime environment for POSIX application deployment on MS-Windows. If you want POSIX application deployment on this platform, please consider Cygwin instead. Primarily intended for use by developers working on the native MS-Windows platform, but also available for cross-hosted use, (see note below -- you may need to follow the "read more" link to see it), MinGW includes: A port of the GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers; GNU Binutils for Windows (assembler, linker, archive manager) A command-line installer, with optional GUI front-end, (mingw-get) for MinGW and MSYS deployment on MS-Windows A GUI first-time setup tool (mingw-get-setup), to get you up and running with mingw-get.
1.下载路径:http://sourceforge.net/projects/mingw/files/latest/download?source=files
2. 运行mingw-get-setup.exe之后,一步一步,会打开一个graphic management installer,选择需要安装的compiler。
也可以通过命令行来安装:
2.1 把安装目录下的bin添加到path环境变量下。
2.2
mingw-get install gcc g++ mingw32-make 会安装c/c++编译器和mingw32-make
3. 在D:\python\workspace有一个文件test.c 是一段简单的c代码:
#include <stdio.h>
void main() {
printf("Hello World!\n");
printf("total num is %d",count(10,20));
}
int count(int a,int b)
{
printf("value of a is %d, value of b is %d \n",a,b);
return a+b;
} 3.1编译test.c成test.o
cd到workspace目录下:gcc -c test.c
【3.2.1】把test.o编译成可执行二进制文件test.exe
gcc -o test test.o
【3.2.2】
也可以一个命令实现1/2两步:
gcc test.c -o test
3.3 运行test.exe
在命令行:test
输出结果为:
D:\python\workspace\cTestProject>test
Hello World!
value of a is 10, value of b is 20
total num is 30
相关文章推荐
- c++ primer 学习笔记-第十二章
- [C语言][LeetCode][169]Majority Element
- <C/C++算法>九度OJ题目1516--1557解题练习(十)
- C语言的声明
- CPP线程:生产者与消费者的问题
- C++中static、const初始化
- VC++中关于控件重绘函数/消息 OnPaint,OnDraw,OnDrawItem,DrawItem的区别
- C# 调用C/C++回调函数
- C#调用C/C++动态库 封送结构体,结构体数组
- CPP多线程与可变参数
- C#调用C++方法,C#使用c++方法返回类或结构体
- CPP:动态数组vector是如此之简单,array显得不友好
- vs2010中导入OFFICE库文件的类 excel.h,excel.cpp后出现编译错误的解决办法
- C/C++编程细节(一)——你未必知道
- 黑马程序员-c语言-字符串求公共子类
- C语言字符数组与字符串简介
- C++ 函数返回引用
- c++ 模板函数,类模板,仿函数使用实例代码
- 同一个变量打印char类型和unsigned char 类型,引发的思考
- 关于argc和argv