Anonymous avatar Anonymous committed 5e31d2b

rpath doc

Comments (0)

Files changed (1)

+Making DLL's dependencies relative to origin on Linux
+=====================================================
+
+There is a mechanism called RPATH that controls so called run path which
+takes precedence over LD_LIBRARY_PATH. You can see set RPATHs options by executing
+following command:
+
+.. code-block:: bash
+
+    readelf -d library.so
+
+and search for for RUNPATH attribute.
+
+Normally it stores absolute paths. The trick is that you can make RUNPATH
+relative to origin file by using special $ORIGIN placeholder. To manipulate
+RUNPATH you need an extra piece of software called patchelf. This can be
+downloaded from  http://nixos.org/patchelf.html. At the time it wasnt
+avaialble as ubuntu package so you need to compile it from source.
+
+After you go that installed you can manipulate rpath with it:
+
+.. code-block:: bash
+
+    patchelf --set-rpath '{NEW_RPATH}' library.so
+
+Say you have library a.so that depends on b.so and b.so is located in the same
+directory relative to a. You would tweak this way:
+
+.. code-block:: bash
+
+    patchelf --set-rpath '$ORIGIN' a.so
+
+Now b.so dependency is resolved relatively to a.so origin. You can also use
+relative paths like ``$ORIGIN/../lib`` etc.
+
+To review results use:
+
+.. code-block:: bash
+
+    ldd a.so
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.