1

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.

I was able to modify Makefile to get librtmp.so file:

#SO_VERSION=1
#SO_posix=.${SOX}.${SO_VERSION}
SO_posix=${SOX}

so the file produced file is now 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)
4ntoine
  • 19,816
  • 21
  • 96
  • 220

1 Answers1

2

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.

It follows that your librtmp.so has a DT_SONAME of librtmp.so.. You can confirm that with:

readelf -d librtmp.so | grep SONAME

So what do you need to do to get rid of SONAME? Get rid of -Wl,--soname=... somewhere in your Makefile.

how can i check executable if it uses SONAME or filename

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 
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • how can i check executable if it uses SONAME or filename? – 4ntoine Apr 20 '14 at 12:58
  • In Android NDK r9d, this simple trick does not work, unfortunately. NDK adds DT_SONAME to your shared libs automatically. Worse, if you really try hard and remove this field, then the file name is still **NEEDED** by the dependent shared library. – Alex Cohn Nov 01 '14 at 22:35