我怎样才能知道哪些标志可供 GCC 更轻松地链接库?

发布于 2025-01-07 03:56:30 字数 299 浏览 1 评论 0原文

在阅读某些库的文档时,我看到某些库有一些功能,例如使用这些库编译程序更容易,只需在 GCC 参数中键入“-something”,而不是键入库的路径或使用 pkg (... -- cflag --clibs)。

如何获取系统上当前安装的库或软件包的“-something”列表?

例如,OpenGL 标志: -lGLUT -lGL

当我使用包管理器安装新库时,它们肯定存储在 GCC 的配置文件中,或者 GCC 如何知道如何使用它们?

While reading documentation on some library, I saw that some library have some feature, like compiling program using those library more easier, with just typing '-something' in the GCC argument instead of typing the path to library or using pkg (... -- cflag --clibs).

How can I get the list of those '-something' for libraries or packages currently installed on my system?

For example, OpenGL flags:
-lGLUT -lGL

They are surely stored in a GCC's config file when I use the package manager to install new library, or how GCC would know how to use them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停滞 2025-01-14 03:56:30

这些库存储在任何配置文件中。

如果您检查 GCC 链接选项,您将看到选项“-l”用于选择要链接的库。该选项的作用是在指定路径中查找库。

如果您查看文件夹 /usr/lib,您将看到许多名为 /usr/lib/libgtkspell.so.0.0.0 的文件。这适用于名为 gtkspell 的库。您可以使用 -lgtkspell 链接它,链接器在搜索文件时会自动添加其他部分。

pkg-config 应用程序非常适合需要特殊额外 GCC 标志的库,无论是在编译 (--cflags) 或链接 (--libs) 时>)。但添加到编译/链接的实际标志 pkg-config 只是标准 GCC 标志。

Those libraries are not stored in any configuration file.

If you check the GCC link options you will see an option "-l" which is used to select libraries to link with. What that option does is to look for libraries in a specified path.

If you look in the folder /usr/lib you will see a lot of files named like /usr/lib/libgtkspell.so.0.0.0. This if for a library named gtkspell. You link with it by using -lgtkspell, the linker will automatically add the other parts when searching for the file.

The pkg-config application is good for libraries that need special extra GCC flags, either when compiling (--cflags) or linking (--libs). But the actual flags pkg-config adds to the compilation/linking are just standard GCC flags.

妄断弥空 2025-01-14 03:56:30

我想知道那些标志,因为我不知道给 pkg 提供什么参数。
但我发现它是如何工作的:

在 /usr/lib/pkgconfig 中有我们需要的一切。仅将这些文件之一放入参数 + --cflag 和 --clib 中。

(我不知道我应该查看 /usr/lib/pkgconfig)

I wanted to know those flag, since i didn't know what argument to gave to pkg.
But i found out how it was working:

In /usr/lib/pkgconfig there is everything we need. Only put one of those file in argument, + --cflag and --clib.

(i didnt know i was suppose to look at /usr/lib/pkgconfig)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文