在Windows中,EXE和DLL具有版本信息,至少包括以下字段:
在Linux库/可执行文件中:
发布于 2012-12-19 07:32:44
未显式存储在精灵文件中的版本信息。您在其中拥有的是库的名称,soname,其中包括主要版本。完整版本通常作为库文件名的一部分存储。
如果您有库,比如libtest.so,那么通常有:
libtest.so.1.0.1 -库文件本身,包含完整的版本libtest.so.1 -到libtest.so.1.0.1的符号链接,其名称与soname相同libtest.so -用于链接的到libtest.so.1的符号链接。在库文件libtest.so.1.0.1中,动态部分将有一个名为SONAME的条目,即这个库称为libtest.so.1。当您将程序链接到此库时,链接的程序将将库的soname存储在动态部分的NEEDED条目下。
如果要验证ELF文件到底在哪个文件中,可以尝试运行:
readelf -a -W elffile其中elffile可以是一个可执行文件的库。
如果您只想获得库版本,可以使用:
readelf -d /path/to/library.so |grep SONAMEAFAIK,在可执行文件中没有这样的信息(至少在默认情况下不是这样)。
或者你可以依靠程序本身或者你的打包系统,就像Rahul Patil所写的那样。
发布于 2012-12-19 07:11:42
您可以使用ldconfig -v | grep libraryname,也可以命令有选项command -V或binaryfile --version
例子:
test@ubuntukrb12:~# ls --version
ls (GNU coreutils) 8.13
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.另外,你也可以根据你正在使用的发行版来使用yum或智能。
在RHEL5 5/CENTOS5 5/Fedora中,您可以使用yum info packagename,或者如果安装了它,则使用rpm --version packagename
[root@ldap1 ~]# yum info bind97
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.sin3.sg.voxel.net
* epel: mirror.imt-systems.com
* extras: mirrors.sin3.sg.voxel.net
* updates: mirrors.sin3.sg.voxel.net
Installed Packages
Name : bind97
Arch : i386
Epoch : 32
Version : 9.7.0
Release : 10.P2.el5_8.4
Size : 6.3 M
Repo : installed
Summary : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server
URL : http://www.isc.org/products/BIND/
License : ISC
Description: BIND (Berkeley Internet Name Domain) is an implementation of the DNS
: (Domain Name System) protocols. BIND includes a DNS server (named),
: which resolves host names to IP addresses; a resolver library
: (routines for applications to use when interfacing with DNS); and
: tools for verifying that the DNS server is operating properly.在Ubuntu中,您可以使用aptitude show pkgname或dpkg --version pkgname
root@ubuntukrb12:~# aptitude show bind9utils
Package: bind9utils
State: installed
Automatically installed: yes
Version: 1:9.8.1.dfsg.P1-4ubuntu0.4
Priority: optional
Section: net
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Uncompressed Size: 306 k
Depends: libbind9-80, libc6 (>= 2.14), libdns81, libisc83, libisccc80, libisccfg82
Conflicts: bind9utils
Replaces: bind9 (<= 1:9.5.0~b2-1), bind9 (<= 1:9.5.0~b2-1)
Description: Utilities for BIND
This package provides various utilities that are useful for maintaining a working BIND installation.发布于 2019-02-22 15:24:35
运行此程序以获取版本信息- strings libssl.so.1.0.0 | grep "1\.0"
SSLv3 part of OpenSSL 1.0.2p-fips 14 Aug 2018
OpenSSL 1.0.2p-fips 14 Aug 2018
TLSv1 part of OpenSSL 1.0.2p-fips 14 Aug 2018
DTLSv1 part of OpenSSL 1.0.2p-fips 14 Aug 2018https://unix.stackexchange.com/questions/58846
复制相似问题