clij2-fft

Building the code

Build and install native libraries

The c++ library ‘clij2fft’ implements several FFT based algorithms built on top of clFFT. This library is indepentent of java.

Pre-requisites for all operating systems

clfft

Windows

Windows pre-requisites

Visual Studio Community 2019 c++ compiler
Git for Windows with Bash Terminal

Windows build Instructions

  1. From Start menu run ‘x64 Native Tools Command Prompt for VS 2019’
  2. From the Command Prompt start a bash shell “C:\Program Files\Git\bin\sh.exe”
  3. Run native/cppbuild.sh
  4. If step 3 fails check native/clij2fft/cppbuild.sh and verify that OpenCL and clFFT are installed in the correct locations.
  5. The updated library (clij2fft.dll) and dependencies should now be in the clij2-fft/lib/win64/ directory.

Linux

Linux Pre-requisites

gcc

Linux/MacOSX Build Instructions

  1. From a bash terminal run native/cppbuild.sh
  2. If step 1 fails check native/clij2fft/cppbuild.sh and verify that OpenCL and clFFT are installed in the correct locations.
  3. The updated library (clij2fft.so) and dependencies should now be in the clij2-fft/lib/linux64/ directory.

MacOSX and Mac Silicon Native M1

You will need to install clFFT from here using homebrew.

To build on macosx or mac m1/m2 (arm64) perform the following

  1. From a bash terminal run native/cppbuild.sh
  2. If step 1 fails check native/clij2fft/cppbuild.sh and verify that OpenCL and clFFT are installed in the correct locations.

The macosx the native library libclij2fft needs to be modified with install_name_tool in order for it to be found by libclij2fft.dylib in it’s current directory (ie when both are in /mambaforge/envs/current_environment/lib)

install_name_tool -change libclFFT.2.dylib @rpath/libclFFT.2.dylib ../../../lib/macosx-arm64/libclij2fft.dylib

If targeting both macosx and macosx-arm64 we need to build a universal binary using ‘lipo’

lipo -create -output lib/macosx-universal2/libclFFT.dylib lib/macosx/libclFFT.dylib lib/macosx-arm64/libclFFT.dylib`

We recommend searching the ImageSC Forum for more information. Please ask questions on the forum if previous discussions are unclear.

Build Java Wrapper and Plugin

  1. A 64 bit c++ compiler is needed to create the wrapper. In windows from Start menu run ‘x64 Native Tools Command Prompt for VS 2019’. In Linux/MacOsx make sure a 64 bit c++ compiler (ie gcc) is installed.

  2. Run ‘mvn install -Dgpg.skip’ from the command line or GUI. NOTE: -Dgpg.skip is needed to skip signing if building for testing or local installation.

  3. The maven build is set up to build native wrappers using javacpp and pack the wrapper into the jar.

Build Plugin Only and Install in Fiji

If you do not have a c compiler installed you may want to just build the java part of the plugin.

  1. Run ‘mvn -Djavacpp.skip=true’
  2. Copy the libraries in lib/win64 to your Fiji installation (Fiji.app/lib/win64). (on linux copy to and from ‘lib/linux64’ on mac to and from ‘lib/macosx’).
  3. Copy the output jar (‘target/clij2-fft-x.x.jar’) to Fiji.app/jars.