宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

1.验证有无安装gcc
win+r 调出Run,输入cmd,调出cmd窗口
输入

g++ -v

2安装
在https://sourceforge.net/projects/mingw/
下载MinGW,minimalist GUN for windows
GUN-Gun’s not unix
GCC-GNU Compiler Collection
在MinGW的列表中,勾选希望安装的文件包,然后在菜单中选择Updata Catalogue

设置环境变量,我的电脑->propertise->advanced system setting->Enviroment Variables->User variables->Path->edit->
加入C:\MinGW\bin
该目录下有刚刚安装的gcc.exe g++.exe文件
返回步骤1验证是否安装成功

3编译
写代码存为helloworld.c

#include<stdio.h>
int main)
{
printf“hello ,world!\n”);
return 0;
}

然后编译运行

用-o指定编译后的文件名

g++ helloworld.c -o helloworld
不再生成a.exe,而是helloworld.exe

4编译的时候引入include python.h
发生了一系列报错,后来经过查询,连接出错,可能跟gcc编译器有关。考虑换成tdm-gcc
有人说
MinGW ,只有32位,http://www.mingw.org/
Mingw64,有64位 i686-w64-mingw32
32位 x86_64-w64-mingw32 64位
TDM-GCC w32api 32位的用的MinGW 的,64位用的Mingw64的。

我所使用的系统需要64位,重新安装TDM_GCC,但依然报同样的链接异常。

需要gendef进行编译链接文件的相关内容。后续日记里再写。