Gmssl 编译去掉版本号以及改库名

1. 下载源码

https://github.com/guanzhi/GmSSL.git

解压,进入源码目录

2. 编译

为了避免与系统的 libssl.so 和 libcrypto.so 冲突,建议设置 prefix。

./config --prefix=/your/lib/save/path

打开 Makefile 文件,大概18行

SHLIB_MAJOR=1

SHLIB_MINOR=1

改为空

SHLIB_MAJOR=

SHLIB_MINOR=

3. 如果想给动态库换个名字

打开 Makefile.shared 文件,大概 167行

-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX

将 -soname

改为 -soname=libgm$(LIBNAME).so

4. 在 /your/lib/save/path/lib 目录下可以看到:

total 11140

drwxr-xr-x. 2 root root 37 Feb 13 11:17 engines-1.1

-rw-r--r--. 1 root root 6208214 Feb 13 11:17 libcrypto.a

-rwxr-xr-x. 1 root root 3808352 Feb 13 11:17 libcrypto.so

-rwxr-xr-x. 1 root root 558128 Feb 13 11:17 libssl.so

-rw-r--r--. 1 root root 826460 Feb 13 11:17 libssl.a

drwxr-xr-x. 2 root root 58 Feb 13 11:17 pkgconfig

5. 用 readelf 查看 so 里面的 soname

readelf libcrypto.so -a | grep soname

0x000000000000000e (SONAME) Library soname: [libgmcrypto.so]

说明改成功了。

6. 将 libcrypto.so libssl.so 重命名下。

libgmssl.so libgmcrypto.so

7. 使用的时候记得链接好,即可。

发布了37 篇原创文章 · 获赞 14 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/xiaod_szu/article/details/104292714