JonasLamy / LiverVesselness

Repository for Vesselness algorithms
Other
44 stars 9 forks source link

Issue building the project #6

Closed yanarof closed 9 months ago

yanarof commented 9 months ago

Hello, I am currently trying to build the project LiverVesselness, and I'm struggling to build it:

This ~script is my current attempt at building the code

#!/bin/bash

#cmake version 3.22.1
#ubuntu 22.04
sudo apt install libmkl-dev ninja-build #special requirements for building ITK

vess_path='/home/yanarof/LiverVesselness'

parentpath=$(dirname "$vess_path")
cd $parentpath

git clone https://github.com/JonasLamy/LiverVesselness.git

#Building FFTW (requirements for ITK's FFTW)
cd ${vess_path}/lib
wget https://www.fftw.org/fftw-3.3.10.tar.gz
tar xzvf fftw-3.3.10.tar.gz
cd fftw-3.3.10
./configure --enable-openmp --enable-float
#./configure --prefix=${vess_path}/lib/fftw-3.3.10/build/  --enable-openmp #specify the install directory
make -j4
sudo make install #will install system wide

#Building ITK
# as suggested here: https://github.com/InsightSoftwareConsortium/ITK/issues/3706
cd ${vess_path}/lib
git clone https://github.com/InsightSoftwareConsortium/ITK.git
cd ITK
mkdir build ; cd build
cmake -DITK_USE_MKL=ON -DITK_USE_FFTWD=ON -DMKLROOT=/opt/intel/oneapi/mkl/2022.4.304 -DITK_USE_SYSTEM_FFTW=ON -GNinja ..
ninja && ctest -j3

#Building ITK (building error)
#cd ${vess_path}/lib
#git clone https://github.com/InsightSoftwareConsortium/ITK.git
#cd ITK
#mkdir build ; cd build
#cmake -DModule_Thickness3D=ON -DITK_USE_SYSTEM_FFTW=ON -DITK_USE_FFTWD=ON -DITK_USE_FFTWF=ON ..
#make -j8 #takes a long time

#Building vcpkg
cd ${vess_path}/lib
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install jsoncpp
git submodule update --init

#Building Boost
cd ${vess_path}/lib
git clone https://github.com/boostorg/boost
cd boost
git submodule update --init

#Cloning pybind
cd ${vess_path}/RORPO/pyRORPO
git clone https://github.com/pybind/pybind11.git

#Building LiverVesselness
cd ${vess_path}
mkdir build ; cd build

cmake -D ITK_DIR="${vess_path}/lib/ITK/build" \
        -D BOOST_ROOT="${vess_path}/lib/math/build" \
        -D jsoncpp_DIR="${vess_path}/lib/vcpkg/installed/x64-linux/share/jsoncpp" \
      ..

make #This throws an error

Here, I am getting an error at the end (the last make) due to boost.math....bessel not being found

...
In file included from /home/yanarof/LiverVesselness/src/Filters/oof_GM.cxx:6:
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux_GM.h:15:10: fatal error: boost/math/special_functions/bessel.hpp: No such file or directory
   15 | #include "boost/math/special_functions/bessel.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/OOF_GM.dir/build.make:76: CMakeFiles/OOF_GM.dir/src/Filters/oof_GM.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:545: CMakeFiles/OOF_GM.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/yanarof/LiverVesselness/src/Filters/oof.cxx:6:
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.h:15:10: fatal error: boost/math/special_functions/bessel.hpp: No such file or directory
   15 | #include "boost/math/special_functions/bessel.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/OOF.dir/build.make:76: CMakeFiles/OOF.dir/src/Filters/oof.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:519: CMakeFiles/OOF.dir/all] Error 2

Do you know which step of this build process I am doing wrong ?

JonasLamy commented 9 months ago

Hello Yanarof,

Sorry for the delayed answer.

It seems that the boost library is not found when you build. I assume you are on Windows. Either add boost on your system and update the PATH variable, or modify the CMakeLists.txt to add a find_package( ) with Boost.

yanarof commented 9 months ago

I am building the project under ubuntu 22.04 with cmake version 3.22.1

@omerveille told that I forgot to install boost library so I installed the thing with sudo apt-get install libboost-all-dev

Now, when building the LiverVesselness, the error is again due to the fftw library not being found

Consolidate compiler generated dependencies of target Antiga
[  3%] Built target Antiga
Consolidate compiler generated dependencies of target Frangi
[  7%] Built target Frangi
Consolidate compiler generated dependencies of target Jerman
[ 11%] Built target Jerman
Consolidate compiler generated dependencies of target Zhang
[ 14%] Built target Zhang
Consolidate compiler generated dependencies of target Meijering
[ 18%] Built target Meijering
Consolidate compiler generated dependencies of target Sato
[ 22%] Built target Sato
Consolidate compiler generated dependencies of target OOF
[ 24%] Building CXX object CMakeFiles/OOF.dir/src/Filters/oof.cxx.o
In file included from /home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.h:75,
                 from /home/yanarof/LiverVesselness/src/Filters/oof.cxx:6:
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.hxx: In member function ‘void itk::OptimallyOrientedFlux<TInputImage, TOutputImage>::GenerateData()’:
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.hxx:249:34: error: ‘FFTWForwardFFTImageFilter’ in namespace ‘itk’ does not name a template type; did you mean ‘ForwardFFTImageFilter’?
  249 |    using FFTType = typename itk::FFTWForwardFFTImageFilter<TInputImage>;
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  ForwardFFTImageFilter
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.hxx:250:22: error: ‘FFTType’ has not been declared
  250 |     auto FFTfilter = FFTType::New();
      |                      ^~~~~~~
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.hxx:253:41: error: ‘FFTType’ has not been declared
  253 |     using FFTOutputImageType = typename FFTType::OutputImageType;
      |                                         ^~~~~~~
/home/yanarof/LiverVesselness/include/OOF/itkOptimallyOrientedFlux.hxx:254:41: error: ‘FFTType’ has not been declared
  254 |     using FFTOutputPixelType = typename FFTType::OutputPixelType;
  ....... 

And I do get this warning when building ITK(however it does compile):

...
-- The following OPTIONAL packages have not been found:
 * KWStyle (required version >= 1.0.1)
 * cppcheck
 * FFTW
 ...

I tried with a different version of ITK (ITK-5.3.0), but I get the same error

This probably means that the problem comes from ITK and FFTW .. maybe ?

Which versions and parameters are you using and parameters when building the project ? Edit: build_livervessels.txt I attached the current attempt at building the code

JonasLamy commented 9 months ago

I've used ITK up to 5.1, so it shouldn't be a problem.

One way around having difficulties with FFTW, is to let ITK build the library itself. Actually, there is an ITK flag for this. I would advise you use ccmake, so you can easily find the corresponding FLAG name and activate it. This way, itk will compile a local install of FFTW that should not conflic with anything

yanarof commented 9 months ago

So for the ITK version 5.1, it's not possible, because LiverVesselness has a 5.2 requirement in the CMakeLists.txt, and even replacing with find_package(ITK 5.2 REQUIRED) in the cmake, I get other errors ...

In the end I was able to use ITK 5.2.1 (not 5.2.0 not 5.3.0), and livervesselness was able to generate all the binaries

I also had to add a #include <optional> in the file ~/LiverVesselness/RORPO/Image/include/Image/Image_IO_ITK.hpp even though we are using the set(CMAKE_CXX_STANDARD 17)

This is how I was able to build it in the end:

#!/bin/bash

#cmake version 3.22.1
#Ubuntu 22.04

sudo apt-get install libboost-all-dev

#optionnal for ITK: kwstyle, cppcheck

vess_path='/home/yanarof/LiverVesselness'

parentpath=$(dirname "$vess_path")
cd $parentpath

git clone https://github.com/JonasLamy/LiverVesselness.git

# Building ITK
git clone -b v5.2.1 https://github.com/InsightSoftwareConsortium/ITK ITK-5.2.1
cd ITK-5.2.1
mkdir build ; cd build
cmake -DModule_Thickness3D=ON \
    -DBUILD_SHARED_LIBS=OFF \
    -DITK_USE_FFTWD=ON \
    -DITK_USE_FFTWF=ON \
    -DITK_USE_SYSTEM_FFTW=OFF \
    -DBUILD_EXAMPLES=OFF \
    ..
make -j8

#Install vcpkg
cd ${vess_path}/lib
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install jsoncpp
git submodule update --init

#Build Jsoncpp
cd ${vess_path}/lib
git clone https://github.com/open-source-parsers/jsoncpp.git
cd jsoncpp
mkdir build ; cd build
cmake ..
make

#Install Boost
cd ${vess_path}/lib
git clone https://github.com/boostorg/boost
cd boost
git submodule update --init

#Install pybind
cd ${vess_path}/RORPO/pyRORPO
git clone https://github.com/pybind/pybind11.git
cd ${vess_path}/RORPO
git submodule update --init

#Building LiverVessels
cd ${vess_path}
mkdir build ; cd build
cmake \
    -D ITK_DIR="${vess_path}/lib/ITK-5.2.1/build" \
    -D BOOST_ROOT="${vess_path}/lib/math/build" \
    -D jsoncpp_DIR="${vess_path}/lib/vcpkg/installed/x64-linux/share/jsoncpp" \
    ..

make -j8

Thank you for the help. You can mark this issue as closed/resolved

JonasLamy commented 9 months ago

I'm glad you managed to get the project to compile ! The setup is always a bit tricky... Enjoy the filters :)