如何修改librtmp Makefile删除版本后缀?
默认情况下,librtmp编译生成librtmp.so.1
文件和符号链接librtmp.so
.我需要没有数字后缀的librtmp.so,因为andorid不支持它.
By default librtmp compile produces librtmp.so.1
file and symlink librtmp.so
. I need to have librtmp.so without number suffix as andorid does not support it.
我能够修改Makefile以获得librtmp.so文件:
I was able to modify Makefile to get librtmp.so file:
#SO_VERSION=1
#SO_posix=.${SOX}.${SO_VERSION}
SO_posix=${SOX}
因此文件生成的文件现在为librtmp.so
so the file produced file is now librtmp.so
但是android无法加载它,因为它仍然尝试加载librtmp.so.
(带点):
But android can't load it as it still tries to load librtmp.so.
(with dot):
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 170 could not load needed library 'librtmp.so.' for 'libffmpeg.so' (load_library[1093]: Library 'librtmp.so.' not found)
如果共享库的DT_SONAME
动态标记为foobar.so.56
,则无论您称呼什么实际文件(例如foo.so
或SONAME
会记录在可执行文件中(作为DT_NEEDED
动态标记),而不是实际的文件名.
If a shared library has DT_SONAME
dynamic tag of foobar.so.56
, then no matter what you call the actual file (e.g. foo.so
, or libbar.so
), when you use that library to link an executable, the SONAME
is recorded in the executable (as DT_NEEDED
dynamic tag), and not the actual file name.
因此,您的librtmp.so
的DT_SONAME
为librtmp.so.
.您可以通过以下方式确认这一点:
It follows that your librtmp.so
has a DT_SONAME
of librtmp.so.
. You can confirm that with:
readelf -d librtmp.so | grep SONAME
那么,要摆脱SONAME
,您需要做什么?摆脱Makefile
中某个位置的-Wl,--soname=...
.
So what do you need to do to get rid of SONAME
? Get rid of -Wl,--soname=...
somewhere in your Makefile
.
如何检查可执行文件是否使用
SONAME
或文件名
可执行文件将始终使用SONAME
(如果存在).您可以通过在可执行文件的动态部分中查找DT_NEEDED
标记来检查可执行文件所需的库:
The executable will always use SONAME
(if present). You can check the libraries that executable needs by looking for DT_NEEDED
tags in the executable's dynamic section:
readelf -d a.out | grep NEEDED