lib{library name}.a/.so 是 Linux 中静态库的命名约定吗? [英] Is lib{library name}.a / .so a naming convention for static libraries in Linux?

查看:13
本文介绍了lib{library name}.a/.so 是 Linux 中静态库的命名约定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近不得不在 Ubuntu 系统上做一些小程序(我是一个非常低级的初学者),我真的只是熟悉 makefile.

I've had to do some minor programming on a Ubuntu system recently (at which I am an extremely low-level beginner) and I'm really just getting familiar with makefiles.

我注意到告诉链接器要包含哪些库的参数始终是 -l{library name},其中相应的库将是/usr/lib 文件夹中名为lib{library name}.a"的东西.

I noticed that the arguments to tell the linker which libraries to include were always -l{library name} where the corresponding library would be something called "lib{library name}.a" in the /usr/lib folder.

我想知道:这是约定吗?我原以为我需要输入 -llibNAME 才能找到一个名为 libNAME.a 的库,但它似乎假定了一个 lib 前缀.

I am wondering: is that a convention? I would have thought I would need to type -llibNAME to find a library called libNAME.a, but it seems to assume a lib prefix.

总是这样吗?我可以在不使用 lib 前缀的情况下命名库吗?

Is this always the case? Can I name a library without using a lib prefix?

推荐答案

你可以任意命名,但是 ld-l 假设一个 lib 前缀适用于静态库和共享库,并且可以追溯到很久以前;您需要明确命名它以使用不带 lib 前缀的名称.

You can name one any way you want, but ld's -l assuming a lib prefix applies to both static and shared libraries and goes back a long way; you'd need to name it explicitly to use one without the lib prefix.

这实际上在现代系统上也很有用:名称 libfoo.so 可以识别为链接时库,而 foo.so 表示实现的共享对象一个运行时插件.或子系统特定前缀代替 lib 来标识特定子系统的插件;例如,参见 pam_*.sonss_*.so.

This is actually useful even on modern systems: a name libfoo.so can be identified as a link-time library, while foo.so indicates a shared object implementing a runtime plugin. Or subsystem-specific prefixes in place of lib to identify plugins for particular subsystems; see for example pam_*.so and nss_*.so.

这篇关于lib{library name}.a/.so 是 Linux 中静态库的命名约定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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