安装好MinGW和MSYS后,需要设置环境变量,然后更好的使用其中提供的小工具。
如果我们使用ls命令查看当前目录下的文件列表,但是得到如下图所示的结果。
ls命令不起作用,这是因为无法找到ls命令。为了解决这一问题,需要修改环境变量。
在命令提示行里输入path,查看当前的环境变量path的值。
环境变量是一个具有特定名字的对象,它包含了一个或者多个应用程序所将使用到的信息。例如path,当要求系统运行一个程序而没有告诉它程序所在的完整路径时,系统除了在当前目录下面寻找此程序外,还应到path中指定的路径去找。用户通过设置环境变量,来更好的运行进程。
可以通过在命令提示符中使用set命令设置路径,这种方式只对当前窗口有效,当窗口关闭后,设置的环境变量失效。
为了永久保留环境变量的修改效果,本文详细介绍具体的操作步骤。
打开“控制面板”。
选择“系统和安全”。
选择“系统”。
选择”系统属性”。
点击“环境变量”。
选取“Path”,进行编辑。
在变量值的编辑框内添加mingw和msys的路径,中间用分号隔开,注意使用半角的分号,也就是英文输入法下的“;”
C:\MinGW\bin;C:\MinGW\msys\1.0\bin
点击“确定”,退出当前操作。再次打开命令提示符,输入path
可以看到新添加的路径,表明修改路径成功。输入输入uname –help查看。
C:\Users\Administrator>uname –help
Usage: uname [OPTION]…
Print certain system information. With no OPTION, same as -s.
-a, –all print all information, in the following order,
except omit -p and -i if unknown:
-s, –kernel-name print the kernel name
-n, –nodename print the network node hostname
-r, –kernel-release print the kernel release
-v, –kernel-version print the kernel version
-m, –machine print the machine hardware name
-p, –processor print the processor type or “unknown”
-i, –hardware-platform print the hardware platform or “unknown”
-o, –operating-system print the operating system
–help display this help and exit
–version output version information and exit
Report bugs to <bug-coreutils@gnu.org>.
C:\Users\Administrator>
表明路径设置成功。
在GNU工具中,自动化项目管理的make命令功能强大,在设置好环境变量的路径后可以通过输入make –help来随时查看make命令的选项帮助。
C:\Users\Administrator>make –help
Usage: make [options] [target] …
Options:
-b, -m Ignored for compatibility.
-B, –always-make Unconditionally make all targets.
-C DIRECTORY, –directory=DIRECTORY
Change to DIRECTORY before doing anything.
-d Print lots of debugging information.
–debug[=FLAGS] Print various types of debugging information.
-e, –environment-overrides
Environment variables override makefiles.
-f FILE, –file=FILE, –makefile=FILE
Read FILE as a makefile.
-h, –help Print this message and exit.
-i, –ignore-errors Ignore errors from commands.
-I DIRECTORY, –include-dir=DIRECTORY
Search DIRECTORY for included makefiles.
-j [N], –jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-k, –keep-going Keep going when some targets can’t be made.
-l [N], –load-average[=N], –max-load[=N]
Don’t start multiple jobs unless load is below N.
-L, –check-symlink-times Use the latest mtime between symlinks and target.
-n, –just-print, –dry-run, –recon
Don’t actually run any commands; just print them.
-o FILE, –old-file=FILE, –assume-old=FILE
Consider FILE to be very old and don’t remake it.
-p, –print-data-base Print make’s internal database.
-q, –question Run no commands; exit status says if up to date.
-r, –no-builtin-rules Disable the built-in implicit rules.
-R, –no-builtin-variables Disable the built-in variable settings.
-s, –silent, –quiet Don’t echo commands.
-S, –no-keep-going, –stop
Turns off -k.
-t, –touch Touch targets instead of remaking them.
-v, –version Print the version number of make and exit.
-w, –print-directory Print the current directory.
–no-print-directory Turn off -w, even if it was turned on implicitly.
-W FILE, –what-if=FILE, –new-file=FILE, –assume-new=FILE
Consider FILE to be infinitely new.
–warn-undefined-variables Warn when an undefined variable is referenced.
This program built for i686-pc-msys
Report bugs to <bug-make@gnu.org>
C:\Users\Administrator>
GNU工具中的编译器是gcc,可以通过输入gcc –help 查看gcc命令的选择。
转载请注明:王杭州的个人网页 » win7下安装MinGW和MSYS并设置环境变量(二)