Seyfime
Seyfime

Reputation: 11

shared library depends on other libraries with hardcoded paths

I'm building opencv but some of the so libraries contain dependencies on other shared libraries whose name contains path elements ../../lib which would cause loading of libraries to fail at runtime.

I've tried to change the build options and have searched online to find out how the problem happened but could not find an answer.

How those path elements have been included in those .so files, and how they can be excluded?

As an example, below it shows one library libopencv_calibd3d.so depends on ../../lib/libopencv_features2d.so. I'd like those ../../lib/ to be removed from the output of the command:

~sample/opencv/test$ objdump -p libopencv_calib3d.so | grep NEEDED
  NEEDED               ../../lib/libopencv_features2d.so
  NEEDED               ../../lib/libopencv_flann.so
  NEEDED               ../../lib/libopencv_highgui.so
  NEEDED               ../../lib/libopencv_imgproc.so
  NEEDED               ../../lib/libopencv_core.so
  NEEDED               libstdc++.so.6
  NEEDED               libm.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libc.so.6

Upvotes: 1

Views: 288

Answers (1)

user8873174
user8873174

Reputation: 13

Based on reading of the another question for shared library without hardcoding full dependency path, there are two ways to get paths encoded:

  • Using -Wl,-rpath..... Somehow you need to remove this.
  • Using like "~/deps/A/lib/libA.so" to link if libA.so doesn't have a SONAME. You need to set a SONAME to libA.so.

Upvotes: 1

Related Questions