question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing a precompiled shared library

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
eli-schwartzcommented, Jan 17, 2022

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?

0reactions
eli-schwartzcommented, Jan 18, 2022

(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…)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Provide pre-compiled library as install(TARGET ...) to other ...
1 Answer 1 ... Command flow install(TARGETS) installs only targets built within project. It doesn't install imported targets. See, e.g., this ...
Read more >
Use prebuilt libraries - NDK - Android Developers
The NDK supports the use of prebuilt libraries, both static and shared. There are two principal use cases for this functionality:.
Read more >
Simulink Shared Library Dependencies - MathWorks
This function allows you to identify the shared libraries required by blocks in your model. If your model contains any blocks that use...
Read more >
Downloading and installing the library - Libtins
There are some precompiled versions of the library that you can download so you don't have to compile it yourself. Windows. The library...
Read more >
Common tasks - 1.56.0 - Boost C++ Libraries
Libraries · Libraries that should be built from source, as in the example above. · Prebuilt libraries which already exist on the system....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found