如何更改GNU GCC的默认搜索路径值以进行常规使用? [英] How to change the default-search-path values for GNU GCC for regular usage?

查看:93
本文介绍了如何更改GNU GCC的默认搜索路径值以进行常规使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GNU GCC编译器环境变量 Default-Search-Path —我正在尝试将GCC环境变量的默认值更改为新的自定义值,以便默认搜索路径将包含任何所需的其他库或包含我想定期使用的头文件.

GNU GCC Compiler Environment Variables Default-Search-Path — I am trying to change default values of GCC environment variables to new custom values so that the default search path will contain any needed additional libraries or include header files that I would like to use on a regular basis.

我的GNU GCC版本是: gcc(MinGW.org GCC Build-2)9.2.0

My version of GNU GCC is: gcc (MinGW.org GCC Build-2) 9.2.0

包括此<…> 的.h头文件的目录,而不是…""的目录,该目录将与.c文件扩展名位于同一目录中.

Include directories for .h header files for this <…> not "…" which would be in the same directory as .c file extension.

  1. CPATH
  2. C_INCLUDE_PATH
  3. CPLUS_INCLUDE_PATH
  4. OBJC_INCLUDE_PATH

库文件目录:

  1. LIBRARY_PATH

我意识到这些是Windows环境变量.
而且我可以简单地创建Windows用户环境变量.

I realized that these are Windows Environment Variables.
And That I could Simply just create Windows User Environment Variables.

这是一条将显示GNU GCC编译器的默认搜索路径的命令.

Here is a command which will show default search paths for GNU GCC Compiler.

cpp -v

这显示包括目录默认搜索路径.

This shows include directory default search path.

gcc -print-search-dirs

这显示了库目录的默认搜索路径.

This shows library directory default search path.

此命令提示符命令告诉我在GNU GCC编译器的安装过程中设置的默认搜索路径,我认为这些被认为是环境变量,并且我希望了解网络上是否有人可以向我提供有关以下内容的网址更改此默认搜索路径值.

This Command Prompt Command tells me the default-search-paths which are set during installation of GNU GCC Compiler I assume these are considered Environment Variables and I am looking to see if anyone on the web could give me any urls in regards to changing this default search path value.

以下是与我正在做的事情有关的一些链接.我使用了这些信息,尽管我仍然无法完成我打算完成的工作.

Here are a few links related to what I am doing. I used that information although I was still unable to accomplish what I was intending to accomplish.

推荐答案

最新 GCC 编译器有一些(可选) .spec 文件.

您可以编辑自己的文件,并且该文件驱动实际的编译过程.如您所知, gcc 主要是启动一些 cc1 / cc1plus 内部程序(然后是 ld )

Recent GCC compilers have some (optional) .spec files.

You could edit yours, and that file drives the actual compilation processes. As you know, gcc is mostly starting some cc1 / cc1plus internal program (then ld)

相反,配置构建过程,例如编辑 GNU make Makefile 或您的 build.ninja 文件(实际上是该文件的生成器),用于 ninja 构建器.

Instead of that, configure your build procedure, e.g. edit your Makefile for GNU make or your build.ninja file (actually, the generator of that file) for ninja builder.

顺便说一句,GNU make具有很多内置规则.使用 make -p 了解它们.

BTW, GNU make has a lot of built-in rules. Use make -p to understand them.

您还可以从 GNU autoconf 中获得启发.

You could also take inspiration from GNU autoconf.

您还可以编写自己的 GCC插件,以实现自己的 #pragma ,它将自定义 gcc 的行为.我不确定这是个好主意.

You could also code your own GCC plugin, implementing your own #pragma which would customize the behavior of gcc. I am not sure it is a good idea.

如何更改默认搜索路径值?

How to change the default-search-path values?

别那样做,学会用GCC代替

您可能会不时希望使用 Clang 编译代码,以检查您的代码代码库不依赖于一个特定的编译器.

don't do that, learn to use GCC instead

You might want, from time to time, to compile your code with Clang, to check that your code base is not tied to one particular compiler.

您可以使用 Frama-C 同时通过 -Wall -Wextra 转换为 gcc (请注意, clang 也接受它们)

You could use Frama-C or the Clang static analyzer on your C code. In some cases, some bugs could be found at compile time. You certainly want to pass explicitly both -Wall and -Wextra to gcc (and notice that clang accepts them also)

PS.这是从 GNU/Linux 的角度来看的.使其适应您的专有操作系统.或考虑获得切换到Linux的许可(另请参见这份草稿资助的报告通过 CHARIOT 欧洲项目).

PS. This is from a GNU/Linux perspective. Adapt that to your proprietary operating system. Or consider getting the permission to switch to Linux (see also this draft report funded by the CHARIOT European project).

这篇关于如何更改GNU GCC的默认搜索路径值以进行常规使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆