]> Sergey Matveev's repositories - go-opus.git/commitdiff
Dynamic linking explanation
authorHraban Luyat <hraban@0brg.net>
Wed, 2 Nov 2016 16:05:51 +0000 (16:05 +0000)
committerHraban Luyat <hraban@0brg.net>
Wed, 2 Nov 2016 16:06:04 +0000 (16:06 +0000)
README.md

index 3cb63c3668e7523652ccc906a3985e0ee8ea3e56..7dca3c7d05950d78d9dd81baeacdd61ca9d7d6ce 100644 (file)
--- a/README.md
+++ b/README.md
@@ -138,9 +138,35 @@ Mac:
 brew install pkg-config opus opusfile
 ```
 
-Note that this will link the opus libraries dynamically. This means everyone who
-uses the resulting binary will need to have opus and opusfile installed (or
-otherwise provided).
+### Linking libopus and libopusfile
+
+The opus and opusfile libraries will be linked into your application
+dynamically. This means everyone who uses the resulting binary will need those
+libraries available on their system. E.g. if you use this wrapper to write a
+music app in Go, everyone using that music app will need libopus and libopusfile
+on their system.
+
+The obvious way to do this is to publish your software through a package manager
+and specify libopus and libopusfile as dependencies of your program. If that is
+not an option, you can compile the dynamic libraries yourself and ship them with
+your software as seperate (.dll or .so) files.
+
+On Linux, for example, you would need the libopus.so.0 and libopusfile.so.0
+files in the same directory as the binary. Set your ELF binary's rpath to
+`$ORIGIN` (this is not a shell variable but elf magic):
+
+```sh
+patchelf --set-origin '$ORIGIN' your-app-binary
+```
+
+Now you can run the binary and it will automatically pick up shared library
+files from its own directory.
+
+Wrap it all in a .zip, and ship.
+
+I know there is a similar trick for Mac (involving prefixing the shared library
+names with `./`, which is, arguably, better), and Windows... probably just picks
+up .dll files from the same dir by default? I don't know. But there are ways.
 
 ## License