回炉篇15—C语言指针(1)之安装
好长时间没有更博了,最近一直在研究C语言,因为想研究计算机基础绕不开C语言,所以一咬牙就开始学习C语言了,C与Java大部分还是相通的,入门起来并不会十分费力,接下来先教大家如何在自己的电脑上安装gcc。
以win10的电脑为例:
1.下载
download: http://sourceforge.net/projects/mingw/files/latest/download?source=files
2.安装
3.添加环境变量:右键我的电脑→属性→高级系统设置→环境变量→系统变量
在左侧的列表中输入gcc中bin目录的路径添加到path中
4.继续安装,双击.exe文件,在打开的图形界面中勾选需要安装的项
5.打开命令行,键入gcc -v和make -v以查看是否安装
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>make -v
GNU Make 3.82.90
Built for i686-pc-mingw32
Copyright (C) 1988-2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
测试:
新建test.c文件:
# include <stdio.h>
int main()
{
printf("%s\n","hello world");
return 0;
}
在命令行中cd到当前path,进行编译:gcc text.c -o test.exe即可运行test.exe
在命令行输入test1.exe
出现
运行成功