diff --git a/Provide-native-lib-for-libsignal.md b/Provide-native-lib-for-libsignal.md index 55e367c..d55f33a 100644 --- a/Provide-native-lib-for-libsignal.md +++ b/Provide-native-lib-for-libsignal.md @@ -1,20 +1,46 @@ -The latest libsignal-service requires [libsignal-client](https://github.com/signalapp/libsignal-client), a native (rust) library, for the protocol implementation. Additionally for the new v2 groups libsignal-service requires [libzkgroup](https://github.com/signalapp/zkgroup), another native (rust) library. -You need to use the library files that are compiled for your CPU architecture and operating system. +# Native libraries -Do note that signal-cli already comes pre-bundled with the linux (with a recent enough gnu libc, see [#643](https://github.com/AsamK/signal-cli/issues/643)) x86_64 version of zkgroup and libsignal-service, so if you are on that platform then you should be able to use signal-cli with no issues. +Signal-cli depends on a [libsignal-client](https://github.com/signalapp/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. -**Update:** pre-compiled libraries for most popular platforms are now available in a [GitHub actions repo](https://github.com/exquo/signal-libs-build) (see [#662](https://github.com/AsamK/signal-cli/discussions/662)). +Signal-cli releases include the pre-compiled binaries for x86_64 Linux (with a recent enough version of `glibc`, see [#643](https://github.com/AsamK/signal-cli/issues/643)). For other platforms the library needs to be compiled from source. -# libsignal-client -### Building libsignal-client yourself -Go to the [releases page](https://github.com/signalapp/libsignal-client/releases) and download the source for the libsignal-client version used by signal-cli (**Check the version of signal-client....jar in the (build/install/signal-cli/)lib folder** - as of 2021-09-04 it's v0.9.4 release). +##### zkgroup + +Note: prior to libsignal-client `v0.10.0` (i.e. prior to and including signal-cli `v0.9.2`) another rust library has been required - [zkgroup](https://github.com/signalapp/zkgroup/). See [older version of this page](https://github.com/AsamK/signal-cli/wiki/Provide-native-lib-for-libsignal/013fa8aeaf47cbc72750f0774ffc9880aa09fe0c#libzkgroup) for building instructions. + + +## Pre-built + +Pre-compiled versions of signal-cli for most popular platforms are available in +https://github.com/exquo/signal-libs-build/ + +It is planned to eventually include them in this repository's releases ([#677](https://github.com/AsamK/signal-cli/issues/677)). + + +## Manual build + +### Dependencies -You will need to install the following software: - JDK - gradle - rust (Guide [here](https://www.rust-lang.org/tools/install)) - protocol buffer compiler ("apt install protobuf-compiler") +#### Download libsignal-client source + +Clone [libsignal-client](https://github.com/signalapp/libsignal-client) with `git`, or download the "Source code" file from the [releases page](https://github.com/signalapp/libsignal-client/releases/) (see below for choosing the version from the releases). + +##### Determine the required libsignal-client version + +Every signal-cli release requires a specific version of libsignal-client. The version number is a part of a `signal-client-java-.jar` filename in signal-cli's `lib` directory. For instance, for signal-cli v0.9.2, the file is + + signal-cli-0.9.2/lib/signal-client-java-0.9.7.jar + +So the required libsignal-client version is `0.9.7`. + + +### Build + Once everything is setup, navigate to the root of the libsignal-client codebase: ```sh $ cd java @@ -22,43 +48,33 @@ $ # Prevent building the android library $ sed -i "s/, ':android'//" settings.gradle $ ./build_jni.sh desktop ``` -Then the native lib can be found in the libsignal-client root directory: `target/release/libsignal_jni.so` +Then the native lib can be found in the libsignal-client sub-directory: `target/release/libsignal_jni.so` (the file extension will be `.dylib` on MacOS and `.dll` on Windows, instead of `.so`). + ### Using the new libsignal-client lib file -Once you have your library file, it can be bundled in the root of the `signal-client-java-*.jar` file (but only for one architecture at a time). Only if there is no bundled file will libsignal search the library path (`java.library.path`) for the `.dylib`/`.so`/`.dll` file. +Once you have your library file, it can be bundled in the root of the `signal-client-java-*.jar` file (but only for one architecture at a time). -The linux x86_64 version is bundled by default. For other systems, you need to remove the bundled lib from the jar file +First, the currently bundled file needs to be removed: - zip -d build/install/signal-cli/lib/signal-client-java-*.jar libsignal_jni.so + zip -d signal-cli/lib/signal-client-java-*.jar libsignal_jni.so -# libzkgroup +For signal-cli to be able to use the newly compiled library file, it can either be bundled into the `.jar` file with -There are already a few pre-compiled library files for a few popular platforms in the [releases](https://github.com/signalapp/zkgroup/releases) that can be downloaded. The `.dylib` is for macOS, the `.so` files are for linux systems and the `.dll` is for Windows. If you are on an architecture/OS that doesn't have a pre-built library (Such as the Raspberry Pi) then you'll need to compile the library yourself. + zip signal-cli/lib/signal-client-java-*.jar libsignal_jni.so -### Building libzkgroup yourself +or be placed on the Java library path (see below). Only if there is no bundled file will libsignal search the library path (`java.library.path`) for the `.dylib`/`.so`/`.dll` file. -I recommend going to the releases page and downloading the source for the latest zkgroup build, just in case master is unstable. You will need to install the following software: -- JDK -- gradle -- rust (Guide [here](https://www.rust-lang.org/tools/install)) +Note: on Windows, bundling the compiled `signal_jni.dll` file does not seem to work: see [#517](https://github.com/AsamK/signal-cli/issues/517). -Once everything is setup, navigate to the root of the zkgroup codebase and check the makefile to see if your platform is there (Eg. `mac_dylib` for mac). If it is, run `make [PLATFORM]`. If your platform isn't present, then run `make libzkgroup` instead. -### Using the new zkgroup lib file +#### Java library path -Once you have your library file, it can be bundled in the root of the `zkgroup-java-*.jar` file (but only for one architecture at a time). Only if there is no bundled file will libsignal search the library path (`java.library.path`) for the `.dylib`/`.so`/`.dll` file. - -The linux x86_64 version is bundled by default. For other systems, you need to remove the bundled lib from the jar file - - zip -d build/install/signal-cli/lib/zkgroup-java-*.jar libzkgroup.so - -## Library path -### Finding the default `java.library.path` +##### Finding the default `java.library.path` This [Java program](https://stackoverflow.com/a/20498049) can output any system property, including `java.library.path`. Note that there may be multiple paths to choose from, they are separated with a colon. -### Overriding `java.library.path` +##### Overriding `java.library.path` 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` ```bash