DIPlib¶
Building¶
Matlab dependencies¶
- https://www.mathworks.com/support/requirements/
- https://www.mathworks.com/support/requirements/openjdk.html
Windows¶
Building with Matlab R2024 in Windows 11.
Prerequisites¶
- Windows 11 (tested)
- Matlab R2024b (tested)
- Visual Studio 2022 (depends on Matlab version, check: https://www.mathworks.com/support/requirements/)
- CMake https://cmake.org/download/
- GLFW https://www.glfw.org/download.html
- FFTW3 https://www.fftw.org/install/windows.html
- Java OpenJDK 21 (depends on Matlab version, check: https://www.mathworks.com/support/requirements/openjdk.html)
- Bio-formats
bioformats_package.jarhttps://www.openmicroscopy.org/bio-formats/downloads/ - View5D https://github.com/bionanoimaging/View5D/releases
Preparation¶
- Install Matlab, Visual Studio and CMake
- Move
bioformats_package.jarto$HOME\src\, now referred to asSRC - Unpack GLFW, FFTW3, OpenJDK and View5D in
SRC - Download DIPlib release and unpack in
$SRC. The resulting directory is now referred toDIPSRC -
In the FFTW3 directory, create
libfiles https://www.fftw.org/install/windows.htmllib /def:libfftw3-3.def lib /def:libfftw3f-3.def lib /def:libfftw3l-3.def -
Create
$DIPSRC\targetdirectory - Remove previously build
$HOME\DIPlib, now referred to asDIPROOT
Build¶
Open Developer PowerShell for VS 2022 and execute the following commands in the shell:
Note: try at first without defining MATLAB_ROOT as CMake can mostly find this on its own.
cd $DIPSRC\target
cmake .. `
-DMATLAB_ROOT="C:/Program Files/MATLAB/R2024b" `
-DGLFW_LIBRARY="$SRC/glfw-3.4.bin.WIN64/lib-vc2022/glfw3.lib" `
-DGLFW_INCLUDE_DIR="$SRC/glfw-3.4.bin.WIN64/include" `
-DFFTW3_LIBRARY_FFTW3="$SRC/fftw-3.3.5-dll64/libfftw3-3.lib" `
-DFFTW3_LIBRARY_FFTW3F="$SRC/fftw-3.3.5-dll64/libfftw3f-3.lib" `
-DFFTW3_INCLUDE_DIR="$SRC/fftw-3.3.5-dll64" `
-DDIP_ENABLE_FFTW="1" `
-DJAVA_HOME="$SRC/jdk-21" `
-DCMAKE_INSTALL_PREFIX="$DIPROOT" `
-DCMAKE_BUILD_TYPE="Release" `
-DDIP_BUILD_PYDIP="0"
Which will give you eventually:
--------------------------------------
DIPlib CONFIGURATION REPORT
* PROJECT_VERSION: 3.6.0
* DIP_COPYRIGHT_YEAR: 2025
* C++ compiler: MSVC 19.44.35220.0
* C++ compiler flags: /DWIN32 /D_WINDOWS /EHsc /bigobj /O2 /Ob2 /DNDEBUG
* Build type: Release
* Building shared library
* Library installed to: C:/Users/rligteringen/DIPlib/bin
* Binaries installed to: C:/Users/rligteringen/DIPlib/bin
* Import library installed to: C:/Users/rligteringen/DIPlib/lib
* Header files installed to: C:/Users/rligteringen/DIPlib/include
* dox++ program not configured, no documentation can be generated
* Using OpenMP for multithreading
* Stack trace recording enabled
* Asserts disabled
* Unicode support enabled
* Using 64-bit PRNG
* ICS file IO enabled, with zlib
* TIFF file IO enabled, with zlib, with JPEG
* JPEG file IO enabled
* PNG file IO enabled
* Using FFTW3 (GPL)
* Not using FreeType
* Unit test code included
* DIPviewer module added to 'all' with window managers: GLFW
* DIPjavaio module added to 'all' target with interfaces: Bio-Formats
* DIPjavaio compiled using Java version 21 and targeting 1.8
* PyDIP module not configured
* DIPimage toolbox added to 'all' target
* DIPimage toolbox compiled for MATLAB R2024b
* DIPviewer Java bindings added to 'all' target, compiled using Java version 21 and targeting 1.8
* DIPimage toolbox installed to: C:/Users/rligteringen/DIPlib/share/DIPimage
* DIPimage User Manual cannot be created (dox++ program not configured)
--------------------------------------
Then continue:
cmake --build . --config release
cmake --install . --config release
And copy the external libraries:
Note that the View5D is renamed during the copy
cp $SRC\fftw-3.3.5-dll64\libfftw3-3.dll $DIPROOT\bin
cp $SRC\fftw-3.3.5-dll64\libfftw3f-3.dll $DIPROOT\bin
cp $SRC\View5D_-2.5.5-SNAPSHOT-jar/View5D_-2.5.5-SNAPSHOT.jar $DIPROOT\share\DIPimage\private\View5D.jar
cp $SRC\bioformats_package.jar $DIPROOT\share\DIPimage\private
The release has now been build and completed and can be used in Windows.
The ease the configuration of Matlab for DIPlib, use the following dipstart.m Matlab script:
%% This script adds the DIPlib toolbox to Matlab
%% It must be started everytime you start Matlab
%% This can be automated by adding this script to your `startup.m`
%% The `startup.m` is located in `userpath`
% change diproot to path where DIPlib is installed
diproot="$HOME\DIPlib\";
addpath(fullfile(diproot, "share\DIPimage\"));
setenv('PATH', fullfile(diproot, "bin\")+';'+getenv('PATH'));