C++ 向 MinGW 添加额外的包含/lib 路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4537377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 15:40:48  来源:igfitidea点击:

Add extra include/lib paths to MinGW

c++qtincludemingw

提问by delaccount992

I would like to add some extra include/lib directories besides the default ones for MinGW to search upon compilation. The reason for this is because the hard drive I currently have MinGW installed into is nearly full and so I had to install Qt into my second one instead. Thus, how can I have MinGW include the Qt files by default?

除了 MinGW 在编译时搜索的默认目录之外,我想添加一些额外的 include/lib 目录。原因是因为我目前安装 MinGW 的硬盘快满了,所以我不得不将 Qt 安装到我的第二个中。因此,如何让 MinGW 默认包含 Qt 文件?

回答by Piotr Dobrogost

You can set environment variables CPLUS_INCLUDE_PATHfor include directories and LIBRARY_PATHfor library directories. More information can be found in Environment Variables Affecting GCC

您可以CPLUS_INCLUDE_PATH为包含目录和LIBRARY_PATH库目录设置环境变量。更多信息可以在影响 GCC 的环境变量中找到

回答by ismail

Use -Idirective for extra includes and -Ldirective for extra library paths such as:

-I指令用于额外的包含和-L指令用于额外的库路径,例如:

g++ [...] -I C:\qt\include -L C:\qt\lib

You can use multiple -Iand -Loptions.

您可以使用多个-I-L选项。