Provide native lib for libsignal - AsamK/signal-cli GitHub Wiki
signal-cli depends on the libsignal-client library. It is a rust library and needs to be compiled for a specific processor architecture and operating system that it will be used on.
signal-cli releases include the pre-compiled binaries for x86_64 Linux (with a recent enough version of glibc, see #643), Windows and macOS. For other platforms the library needs to be compiled from source.
Builds for some additional platforms are available in
-
https://github.com/exquo/signal-libs-build/
-
Linux:
- amd64/x86_64 (variant 1 requires
glibcv2.30 or newer, variant 2 requiresmusl libc) - arm64/aarch64, armv7, i386 (these require
glibcv2.30 or newer)
- amd64/x86_64 (variant 1 requires
- macOS: amd64/x86_64, arm64/aarch64 (these require Darwin v14 or newer)
- Windows: amd64/x86_64
-
Linux:
-
https://media.projektzentrisch.de/temp/signal-cli/
-
Linux: amd64/x86_64, arm64/aarch64, armv7, i686, loong64, mips64, mips64el, mips, mipsel, powerpc, ppc64, ppc64el, riscv64, s390x, sparc64
- all artefacts require
glibcv2.30 (loong64: v2.36) or newer
- all artefacts require
-
Linux: amd64/x86_64, arm64/aarch64, armv7, i686, loong64, mips64, mips64el, mips, mipsel, powerpc, ppc64, ppc64el, riscv64, s390x, sparc64
-
https://media.projektzentrisch.de/temp/signal-cli/tests/
- Artefacts that require
muslinstead ofglibc(only briefly tested in Alpine Linux containers):libsignal_jni_soNNNN_ubuntu2004_{amd64,i686,arm64,armv7,loong64,mips64,mips64el,mips,mipsel,ppc64el,riscv64,s390x}-musl.gz
- Artefacts cross-built against header files and libraries of previous, still supported Ubuntu LTS releases:
-
libsignal_jni_soNNNN_ubuntu1804_{amd64,i686,arm64,armv7,mips64,mips64el,mips,mipsel,powerpc,ppc64,ppc64el,riscv64,s390x,sparc64}.gz(these requireglibcv2.27 or newer) -
libsignal_jni_soNNNN_ubuntu1604_{ppc64,ppc64el}.gz(these requireglibcv2.22 or newer) -
libsignal_jni_soNNNN_ubuntu1604_{amd64,i686,arm64,armv7,mips64,mips64el,mips,mipsel,powerpc,s390x,sparc64}.gz(these requireglibcv2.18 or newer)
-
- Artefacts cross-built against header files and libraries of the unsupported older Ubuntu release 13.10:
-
libsignal_jni_soNNNN_ubuntu1310_arm64.gz(requiresglibcv2.17 or newer) -
libsignal_jni_soNNNN_ubuntu1310_{amd64,armv7,i686}.gz(these requireglibcv2.16 or newer)
-
- Artefacts that require
- JDK
- gradle
- rust (Guide here)
Clone libsignal-client with git, or download the "Source code" file from the releases page (see below for choosing the version from the releases).
Every signal-cli release requires a specific version of libsignal-client. The version number is a part of a libsignal-client-<VERSION>.jar filename in signal-cli's lib directory. For instance, for signal-cli v0.10.5, the file is
signal-cli-0.10.5/lib/libsignal-client-0.15.0.jar
This is the file path if you have downloaded a signal-cli release. If you have built signal-cli from source, the path will be
signal-cli/build/install/signal-cli/lib/libsignal-client-0.15.0.jar
So the required libsignal-client version is 0.15.0.
Once everything is setup, navigate to the root of the libsignal-client codebase:
$ cd java
$ ./build_jni.sh desktopThen the native lib can be found in the folder: client/src/main/resources/libsignal_jni_amd64.so (amd64 is architecture specific and the file extension will be .dylib on MacOS and .dll on Windows, instead of .so).
For this option, the java part of libsignal-client must be built as well. Run the following command in the libsignal-client java folder.
# Run in libsignal-client/java folder
$ ./gradlew --no-daemon :client:assemble -PskipAndroid=trueThen build signal-cli with the libsignal_client_path option to use that jar file.
# Run in signal-cli folder
$ ./gradlew -Plibsignal_client_path="/PATH/TO/libsignal-client/java/client/build/libs/libsignal-client-0.15.0.jar" buildOr this command to build the signal-cli graalvm native version.
# Run in signal-cli folder
$ ./gradlew -Plibsignal_client_path="/PATH/TO/libsignal-client/java/client/build/libs/libsignal-client-0.15.0.jar" nativeCompileFinally after doing a
$ ./gradlew -Plibsignal_client_path="/PATH/TO/libsignal-client/java/client/build/libs/libsignal-client-0.15.0.jar" installDistone can find the signal-cli script in /PATH/TO/libsignal-client/java/client/build/install/signal-cli/bin/signal-cli
Once you have your library file, it can be bundled in the root of the libsignal-client-*.jar file.
First, the currently bundled file needs to be removed:
zip -d signal-cli/lib/libsignal-client-*.jar libsignal_jni_amd64.so
For signal-cli to be able to use the newly compiled library file, it can either be bundled into the .jar file with
zip signal-cli/lib/libsignal-client-*.jar libsignal_jni_amd64.so
or be placed on the Java library path (see below). For this the file needs to be renamed to libsignal_jni.so. Only if there is no bundled file will libsignal search the library path (java.library.path) for the .dylib/.so/.dll file.
Note: on Windows, bundling the compiled signal_jni.dll file does not seem to work: see #517. (According a comment in that thread, bundling does work if the files are renamed).
You can run the following command to get the value of java.library.path on your system:
java -XshowSettings:properties -version 2>&1 | grep java.library.path
Note that there may be multiple paths to choose from, they are separated with a colon.
If your java.library.path doesn't have any usable paths or you wish to not use the system defaults, then you can override the paths by modifying the final line of build/install/signal-cli/bin/signal-cli
JAVA_LIBRARY_PATH="-Djava.library.path=/your/java/library/path"
exec "$JAVACMD" "$JAVA_LIBRARY_PATH" "$@"Make sure to place your .dylib/.so/.dll file in that folder. Be aware that this method isn't ideal since if you rebuild signal-cli, then the script may be regenerated and you'll need to set this again.