Windows: Environment Variables for MinGW
2015-10-21 22:47
232 查看
Environment variables, as the name implies, are variables that hold directories paths as strings. Environment variables goal is to keep track of important files for the system.
In windows, the most important environment variable is the PATH variable. You can check its content on the command line using the following command:echo %PATH%
Environment variables can also keep track of important files for the compiler (e.g. MinGW GCC) like header files and static and dynamic library files.
Adding, editing or deleting environment variables
To add, modify or delete an environment variable, you'll need to head to Control Panel > System > Advanced System Settings. On the Advanced tab, click on the Environment Variables... button.The following window will pop out.
![](http://2.bp.blogspot.com/-dRVbYyBxY34/UHGq7KXicWI/AAAAAAAAAsc/L1Tr6Lmke2M/s320/environment_variables.png)
List of environment variables
Environment variables are divided in two groups: User variables and System variables. The most important group is the System group. You can create, modify or delete variables using the button New, Edit or Delete respectively.
Let's try editing the Path variable. Click on the Path variable in the System variables group and then click the Edit button.
![](http://2.bp.blogspot.com/-apbDcjyQmL8/UHGrmo_8ykI/AAAAAAAAAsk/BMXWnkX6ZVg/s320/edit_env_var.png)
As you can see, the variable is a list of directory paths separated by the ";" character. The most safe way of adding a new directory is by appending the path as follows:
;C:\mingw\bin
That way there won't be name crashes.
There are many environment variables, let's review the most important ones.
Binary path (PATH)
The PATH (or Path, Windows is case insensitive) variable holds paths to binary files like .exefiles,to commands and to .dll files.
Be careful with this variable, do not delete the default path like System32 and so on. Generally, you'll only need to append new directory paths to this variable.
For example:
Append ";C:\mingw\bin" to the Path variable
Important note: Do NOT create a new Path or PATH (again, Windows is case insensitive) variable in the system variable group or you'll override the default paths and you'll be in trouble.
Include paths (CPLUS_INCLUDE_PATH, C_INCLUDE_PATH)
These variable hold the directory paths to header files (like library header files). Important for linking new installed libraries.Generally you'll need to append the path to a library "include" folder.
For example:
Append ";C:\mingw\include" to the CPLUS_INCLUDE_PATH
CPLUS_INCLUDE_PATH and C_INCLUDE_PATH are pretty much the same. When the compiler looks for a header file, it looks in both variables. So having two variables is only useful for the programmer to keep things tidy.
Library path (LIBRARY_PATH)
This variable hold the directory paths to static library (.lib or .a files). Thisone is also important for linking new libraries.
Generally you'll need to append the path to a library "lib" folder.
For example:
Append ";C:\mingw\lib" to the LIBRARY_PATH
相关文章推荐
- php5.5版本之后 对象复制就是直接引用
- 关于luci的几个问题<一>
- discuz!nt 关于用户头像无法显示、无法重新设置的解决办法
- 实例——自动选项卡
- Cookie / Session / URL重写
- 再读大道至简第四章
- 《代码阅读方法与实践》读书笔记2
- 项目39.2求满足条件n=a!+b!+c!的所有三位数n并输出,其中a,b,c分别为n的百、十、个位数。
- STL学习笔记-list容器(双链表)
- DP动态规划问题(1)
- 2015南阳CCPC H - Sudoku 暴力
- c语言/c++常见面试题
- Linux - 磁盘分区
- SqlServer+Json+S2SH+Android实现访问数据库
- 设计模式总结(经典)
- ListView多项选择功能的实现
- 51nod 1163:最高的奖励 优先队列
- 2015南阳CCPC G - Ancient Go 暴力
- Redis部署管理持久化迁移
- 51nod 1163:最高的奖励 优先队列