-
Notifications
You must be signed in to change notification settings - Fork 744
Building on Windows
This little guide will help you to compile Javacpp-Presets for Windows.
It has been written with Windows 7 64 bit in mind so be carefully when using it on a different Windows version. Especially, avoid installing 32bit software on 64bit systems because it will trigger 32bit environment emulation known as WOW64 and mess things up. This is a major source of subtle bugs! Due to the fact we're targeting the Java Native Interface under the hood, it's important to keep in mind that 32bit JVM won't run 64bit native libraries and vice versa!
You'll need to install the following software packages first:
-
MSYS2 - a lightweight Unix-like shell environment for Windows
Download the appropriate package for your system architecture, run it and choose the following installation path:
C:\msys64
After installation, please follow the instructions given on the MSYS2 site in order to initialize the package manager
pacman
and update system packages.Various projects will require additional tools to build properly - in particular, you'll need tar, unzip and patch. Open the MSYS2 console from "Start" menu and type in the following command:
pacman -S tar unzip patch
-
Windows 7 Platform SDK - You may actually need another SDK if you're running another Windows version.
-
MingW-w64 compiler toolchain - this is a port of of the GNU compiler collection to Windows
Download the installer from the above-mentioned site, run it, choose the installation path to be
C:\mingw64
and architecture = x86_64, threading model = win32, exception handling = SEH and build revision = 2.
-
7zip decompression package - required for uncompressing source code delivered as RPM packages, ZIP or GZIP archives and tarballs.
Please ensure that 7zip executable has been properly installed to
C:\Program Files\7-Zip\7z.exe
-
Maven - one of the most widespread build tools for Java
Detailed installation instructions for Maven can be found here.
-
Now you'll need to add the following code to your Windows PATH:
C:\msys64\usr\bin;C:\mingw64\mingw64\bin
Please ensure that Java and Maven are in your Windows PATH as well.
Fire up the Windows SDK Command Prompt (not the regular command prompt!) and issue the following commands:
bash --version
g++ --version
java -version
mvn --version
If it results in a meaningful output without errors you're ready to proceed with the compilation.
Note on Windows 8.1: Windows SDK 8.1 no longer ships with a complete command-line build environment. Therefore there is no "Windows SDK Command Prompt" under Windows 8.1. Please use the MSYS2 command prompt instead.
Please note that you'll first need to compile and install the parent project - Javacpp.
Then proceed with the compilation of Javacpp-presets as follows:
- download or clone the latest source code and extract it to said
javacpp-presets
- open the Windows SDK Command Prompt (sic!) and issue the following command:
cd javacpp-presets
bash cppbuild.sh -platform windows-x86_64 install leptonica tesseract etc
Specifying the correct target platform via -platform
option is obligatory because the uname command used for platform identification in the cppbuild
scripts does report details on the MSYS2 platform instead of Windows.
TARGET_CPU: unbound variable error!
usually indicates a wrong command prompt. Retry with the Windows SDK Command Prompt.
Note on Windows 8.1:
Because there is NO "Windows SDK Command Prompt" in Windows 8.1 you'll need to use the MSYS2 command prompt instead. The required environment variable TARGET_CPU
should be set manually before calling the build script as follows:
set TARGET_CPU=x64
If everything went well during the previous step, build the Java part as follows:
mvn install --projects .,leptonica,tesseract,etc
Don't forget the period in the beginning of the projects list!