Installing a precompiled shared library
See original GitHub issueI have a precompiled .so file in my project that I would like to install along with my other shared libraries. At the moment, meson install creates binaries that point absolutely to the .so in the projects folders. This would allow the project folder to be deleted without breaking the install.
I currrently have a subproject with the .so that I need with
project('ilasmat', 'c')
pkg = import('pkgconfig')
c = meson.get_compiler('c')
# dep_mat = c.find_library('ILasMatInterface', dirs : meson.current_source_dir())
dep_mat = declare_dependency(
dependencies: c.find_library('ILasMatInterface', dirs : meson.current_source_dir())
)
install_data('ILasMatInterface.so', install_dir: get_option('libdir'))
and
dep_mat = subproject('ilasmat').get_variable('dep_mat')
in the main project meson.build
Neither find_library or declare_dependency works
Without install_data, the .so does not get copied into libdir. In both cases ldd of a compiled .so that uses the precompiled library seems to be linked with the absolute path of the library instead of the name
❯ ldd libmatint.so
linux-vdso.so.1 (0x00007ffd991a1000)
/home/guillaume/workspace/1-rescu/subprojects/ilasmat/ILasMatInterface.so (0x00007f4ec717c000)
libgfortran.so.5 => /lib/x86_64-linux-gnu/libgfortran.so.5 (0x00007f4ec6e97000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4ec6ca5000)
Is there a way to copy the .so to the install and have the library be searched by name like the others? Setting LD_LIBRARY_PATH to the libdir does not help because of the absolute path.
Using find_library in the main meson.build (instead of a subproject) does not help.
I’ve also tried the process suggested in the last part of the issues https://github.com/mesonbuild/meson/issues/6609 Which did not work saying my .so is a not a target.
My install prefix is not a standard one if it’s at all relevant ($HOME/.local)
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (7 by maintainers)
I believe this has nothing to do with rpath, but rather your precompiled lib doesn’t have a soname field. So the linker, when given
path/to/libname.so
rather than-lname
, decides to write the full path rather than the (nonexistent) soname.Can you build the precompiled lib with a soname, even if it doesn’t have anything after
.so
? If not, can you patchelf that before integrating it into your source tree?(It should be noted that meson guarantees any library has a soname, whereas shared_module does not. This has benefits for third party tracking e.g. of symbol evolution. But not all third-party built libraries do the semantically correct thing…)