-
Notifications
You must be signed in to change notification settings - Fork 54
Compiling
- JDK7+
- C++
-
Linux:
gcc
,clang
or equivalent - macOS: XCode with Command Line Utilities
- Windows: Microsoft Visual C++ or mingw-w64
-
Linux:
- Maven, CMake
-
Linux:
sudo apt install maven cmake g++
-
macOS:
brew install maven cmake
-
Windows:
- Manually install Maven from https://maven.apache.org/, adding
mvn.bat
directory to your%PATH%
- Manually install CMake from https://cmake.org/download/, adding
cmake.exe
directory to your%PATH%
- Manually install Maven from https://maven.apache.org/, adding
-
Linux:
- If compiling a Windows target with MSVC, you will need to initialize the environment using vcvarsall for the appropriate target architecture
- win64 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
- win32 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_x86
- winaarch64 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_arm64
mvn # compile for current system - default compile for native host
mvn -P mingw64 # cross-compile using mingw-w64 for Windows
mvn -P m32 # cross-compile using multi-lib for 32-bit Linux/Unix
**MSVC cross compilation**
mvn -P win64 # cross-compile using MVSC for x86_64 Windows
mvn -P win32 # cross-compile using MVSC for x86 Windows
mvn -P winaarch64 # cross-compile using MVSC for Aarch64 Windows (Pending/Unofficial; See pull request 84)
**MacOS Xcode cross compilation
mvn -P intelmac # cross-compile using Xcode for X86_64 MacOS
mvn -P armmac # cross-compile using Xcode for Aarch64 MacOS (Pending/unofficial; See #84)
* **Important:** Call `mvn clean` between different compiler profiles.
* **Note:** For other cross-compilation profiles or platforms search for `CMAKE_TOOLCHAIN_FILE` in `pom.xml`. Each has a respective CMake toolchain file.
* **Note:** When compiling for Windows Arm64 target, make sure MSVC Arm64 Build Tools C++ # 'preferably the latest one' # tttt
* Prefer to skip maven? The project is configured to allow calling `cmake -DCMAKE_TOOLCHAIN_FILE=<...>` directly but the `javah` generated header file must be present.
### Package
Without recompiling native libraries
```bash
mvn -P package,jar-with-dependencies
The build will output two .jar
files in the target/
directory. One archive, which is build by the maven-jar-plugin
, has a classifier which maches the machine's classifier (unless you are doing a cross-compile). This one will contain a freshly compiled library, like libjssc.so
for Linux or a jssc.dll
if you are on Windows. They go into a directory /natives/os_bitness
.
The other .jar
artifact which is generated by the build doesn't use the library compiled by cmake
. It uses the checked-in libraries form the directory src/main/resources-precompiled/natives/
. This jar is the artifact we are going to publish to maven central.
It will contain a broader varieties of OSes and architectures in just one .jar
file, but the libraries checked in into this git repository need to stay updated.
If you do not need a freshly compiled library, you can just execute mvn package -P package
to skip the cmake
compilation and the unit tests.