Install remote module on Windows

Hello,

I would like to install the otb-bv remote module on a Windows system but I don’t understand the steps to do so. I have installed the binary version of OTB for windows: OTB-7.1.0-Win64. I Have also installed cmake and Visual studio 2019 and cloned git depositery of otb-bv and his dependencies Phenotb (https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/wikis/remote-modules#:~:text=Remote%20modules%20allow%20anyone%20to,forking%20the%20remote%20module%20template). I read the section "including a remote module on otb"on the web page (https://wiki.orfeo-toolbox.org/index.php/How_to_write_a_remote_module) explaining how to install the add-on but I can’t find the Modules/remote folder. I found the directory “C:\OTB\OTB-7.1.0-Win64\lib\cmake\OTB-7.1\Modules” with some cmake call of remote module (for example SertitObject.cmake) but how to make the link between this file and the source code of the add-on modules.
Please, can you explain me in details the steps to install the otb_bv module under windows.
Thanks.

Ranfosic

Hello,

I don’t know these remote modules but looking at the github repos activity, I am not sure they are still maintained …

In particular, the CMake file for Phenotb does not follow the skeleton of OTB remote modules. It means that Phenotb cannot be built outside of OTB sources and that if you want to use these modules you have to re-compile OTB entirely from sources.

There are information on how to do this here. To be honest compiling OTB from sources on Windows is not super easy (there us a lot of thing to set up to make it work). But i can try to help you if you want to do it.

CMake scripts to download and compile phenotb and otb-bv are still in the library source code. When compiling OTB you can activate the module with the CMake options activated :

- Module_OTBPhenology = ON
- Module_OTBBioVars = ON

Cédric

Hello,

Thank you for your response.

I also tried to install the module TemporalGapfilling but i have this error message when i configure module with cmake gui:
“CMake Error at src/CMakeLists.txt:19 (add_library):
add_library cannot create target “OTBTemporalGapFilling” because an
imported target with the same name already exists.
CMake Error at src/CMakeLists.txt:20 (target_link_libraries):
Cannot specify link libraries for target “OTBTemporalGapFilling” which is
not built by this project.”

I send to you the log file. Can you give me an example of how to set up cmake please? I don’t understand this step.

Why is there natively a cmake file named OTBTemporalGapFilling in the directory OTB-7.1.0-Win64\lib\cmake\OTB-7.1\Modules?

The module I need is otb-bv, explained that I have to install it from source, but I would like to understand how is it possible to install a remote module for an otb binaries installation?

Thanks

François

CMakeOutput.log (11.4 KB)

Hello,

There are three ways to compile a remote module, if it follows the template (which is not the case here):

  • Compile it inside an build tree : copy the remote module in otb sources in otb/Module/Remote and build OTB with the Cmake option ModuleMyRemoteModule=ON and build otb.
  • Compile it as an external module against an OTB build tree. Build OTB sources, and then build the remote module as a cmake project and give the path of the build tree with the CMakePrefixPath option.
  • Build against an install tree (from example the binary packages), same as above, but you need to set the Cmake option OTB_BUILD_MODULE_AS_STANDALONE to ON.

In the last case, to build a remote module named MyRemoteModule you would do :

#get the source
git clone MyRemoteModule.git
mkdir build && cd build

# Cmake configuration step
cmake ..\MyRemoteModule -DCMake_Build_Type="Release" -DCMake_Prefix_Path="Path\To\OTBBinaries" -DCMake_Install_Prefix="D:\OTB\install" -G"NMake Makefiles"

# Build and install steps
nmake install

TemporalGapFilling is a remote module, but it is packaged with OTB binaries, this is why you can find it in the binaries.

otb-bv depends on TemporalGapFilling and Phenology. As I stated in my previous message, OTBPhenology cannot be built outside of a build tree (solution 1 above). You could try to modify CMake files to make it work. However I think the easiest way to compile otb-bv is to recompile otb. I just tried and managed to build it with MSVC 2019, with a few modifications to the sources (the module is not maintained anymore). Here are the steps I used (you need to have tools like git, Cmake, MSVC installed) :

# First step : go to a otb binary installation dir and uninstall otb. This will leave an xdk that you can use to compile otb. I think this is the easiest way to obtain all otb dependencies on Windows.
cd Path\To\OTBBinaryDIR
tools\uninstall_otb.bat

# Set %WORKING_DIR% where you want to download and build otb  
cd %WORKING_DIR%
# Clone otb sources into %WORKING_DIR%\otb.
git clone https://gitlab.orfeo-toolbox.org/remote_modules/remote-module-template.git

mkdir build
mkdir install
cd build

# CMake command, here I used NMake, but you can use other build system. OTB is tested on WIndows with the Ninja build system.
# This will build the default module and TemporalGapFilling, Phenology and BioVars (otb-bv).  
#If you want to build other module (other applications, or python wrapper, gui ...) you can use cmake gui to tune the configuration
cmake ../otb -G"NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%WORKING_DIR%\install -DCMAKE_PREFIX_PATH=Path\To\OTBBinaries -DCMAKE_CXX_FLAGS:STRING="/DTHROW_QCRITICAL=0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc" -DModule_OTBTemporalGapFilling=ON -DModule_OTBPhenology=ON -DModule_OTBBioVars=ON  -DOTB_USE_GSL=ON -DCMAKE_BUILD_TYPE=Release -DOTB_USE_OPENCV=ON

The CMake command will download the remote modules in otb\Modules\Remote.
Here i had to make a few patches to the sources :

  1. In Phenology sources, otb\Module\Remote\OTBPhenology\app\otbSigmoFitting.cxx : remove SetDocName(...)l53 http://tully.ups-tlse.fr/jordi/phenotb/blob/master/app/otbSigmoFitting.cxx#L53

This method has been removed in OTB 7.0.0

  1. In otb-bv sources, in otb\Module\Remote\OTBBioVars\include\otbMultiLinearRegressionModel.h l146, replace by :
TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType* quality = nullptr, ProbaSampleType* proba = nullptr) const override

The function signature has changed in the base class
http://tully.ups-tlse.fr/jordi/otb-bv/blob/master/include/otbMultiLinearRegressionModel.h#L146

I had to make two additionnal fixes, but you might not need them, depending on your configuration (MSVC version principally) :

  1. OTBTemporalGapFilling : the remote module could not find GSL libraries, adding OTBGSL to the module depency fixed it for me. In otb\Module\Remote\OTBTemporalGapFilling\otb-module.cmak you need to add OTBGSL to the dependencies, the file should be :
set(DOCUMENTATION "Time series gapfilling.")


# OTB_module() defines the module dependencies in GapFilling
# GapFilling depends on OTBCommon and OTBApplicationEngine
# The testing module in GapFilling depends on OTBTestKernel
# and OTBCommandLine

# define the dependencies of the include module and the tests
otb_module(OTBTemporalGapFilling
  DEPENDS
  OTBITK
  OTBCommon
  OTBApplicationEngine
  OTBBoost
  OTBGSL
  TEST_DEPENDS
    OTBTestKernel
    OTBCommandLine
  DESCRIPTION
    "${DOCUMENTATION}"
)

  1. I think this will only happen if you use MSVC 2019, in otb\Modules\ThirdParty\OssimPlugins\src\ossim\AlosPalsar\AlosPlasarData.h line 30 you should add the include :
#include <iostream>

You might no need it depending on your configuration. This is a bug that will be fixed, it has been noticed on linux on recent compilers (gcc 10)

Once you patched the files you can run :

nmake install

And the module should compile (hopefully)

Cédric

1 Like

Hello,

Thank you for your response.
I tried to install OTB from sources as you explained but I still have some errors.
I uninstalled otb binary, clone otb sources ( https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb ) and the modules I need ( TemporalGapFilling, Phenology, otb-bv ).
When I run the cmake configuration ( same syntax as you propose with Nmake in a visual studio command prompt) I have a message error concerning python dependancies. It don’t find python dependancies from OTB as binaries are uninstalled and search in my OSGEO4W folder. I don’t install all PYTHON dependancies from OSGEO4W and I don’t know which ones I need and if it’s really necessary. What are the python requirements to run OTB?
I send you the CmakeError.log. I don’t understand it.

However, I tried to continue the installation after making the source code corrections as you recommended. I run the nmake install command. This starts the compilation but it stops because of the error provided in the attached file (Erreur_OTBBioVars__nmake_install.txt)Erreur_OTBBioVars__nmake_install.txt (5.0 KB) .
Are there other lines in the OTBBioVars source code that need to be modified?CMakeError.log (36.6 KB)

Thanks,

François

Hello François,

sorry for the late reply,

I don’t understand the first error in your logs :

C:\OTB\otb_build\Modules\Remote\OTBBioVars\include\otbMultiLinearRegressionModel.h(153): error C2143: erreur de syntaxe : absence de ';' avant 'void'

there is an error in my previous answer :

  1. In otb-bv sources, in otb\Module\Remote\OTBBioVars\include\otbMultiLinearRegressionModel.h l146, replace by :
TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType* quality = nullptr, >ProbaSampleType* proba = nullptr) const override

The function signature has changed in the base class
http://tully.ups-tlse.fr/jordi/otb-bv/blob/master/include/otbMultiLinearRegressionModel.h#L146

What I meant was replace lines 146 and 147 (the full C++ expression), is it what you did ? (if not, sorry for being unclear on this point …). This could explain the errors.

For Python bindings you need to have Python 3.X and numpy installed (on Linux you need numpy dev libraries, I’m not sure in Windows case). If you don’t need the Python bindings (or the documentation), you can deactivate their compilation (OTB_WRAP_PYTHON=OFF).

Cédric

Hello Cédric,

Thank you for your response.
Yes, I understand your correction and I replace lines 146 and 147.
I just forgot a curly bracket after line 147.
There isn’t any problem for the nmake configuration but I’m getting an error during installation of OTBBioVars. It concerns the dependencies of function otbapp_ProSailSimulator (line 51).
otbProSailSimulator_nmake_error.txt (19.9 KB)
I don’t understand this error. Does it concern C++ code of function otbProSailSimulator.cxx in …\Modules\Remote\OTBBioVars\app?

Thank you for your help.

François

Hello,

it looks like the linker does not find the libraries associated with the OTB application engine (the C++ classes defining applications).

In app/CMakeLists.txt, l14 can you add ${OTBApplicationEngine_LIBRARIES} to the list of linked libraries ? i.e replace :

set(OTBBioVarsApps_LIBRARIES ${otb-module}
  ${GSL_LIBRARY} ${GSL_CBLAS_LIBRARY} ${OTBPhenology_LIBRARIES} ${OTBSimulation_LIBRARIES}
  ${OTBSupervised_LIBRARIES}
  )

by

set(OTBBioVarsApps_LIBRARIES ${otb-module}
  ${GSL_LIBRARY} ${GSL_CBLAS_LIBRARY} ${OTBPhenology_LIBRARIES} ${OTBSimulation_LIBRARIES}
  ${OTBSupervised_LIBRARIES} ${OTBApplicationEngine_LIBRARIES}
  )

Hello Cédric,

Thank you very much for your help.
With the corrections, OTBBioVars is compiled and installed now.
Can you confirm me that if i want to install monteverdi I add the commands -DOTB_USE_QT=ON -DOTB_USE_QWT=ON -DOTB_USE_GLEW=ON -DOTB_USE_OPENGL=ON- to cmake configuration then install it with nmake install?
The cmake (nmake) configuration command will look like this:

cmake C:/OTB/otb_build -G"NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\OTB\otb_build\install -DCMAKE_PREFIX_PATH=C:\OTB\OTB-7.1.0-Win64 -DCMAKE_CXX_FLAGS:STRING="/DTHROW_QCRITICAL=0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc" -DOTB_USE_QT=ON -DOTB_USE_QWT=ON -DOTB_USE_GLEW=ON -DOTB_USE_OPENGL=ON-DModule_OTBTemporalGapFilling=ON -DModule_OTBPhenology=ON -DModule_OTBBioVars=ON  -DOTB_USE_GSL=ON -DCMAKE_BUILD_TYPE=Release -DOTB_USE_OPENCV=ON

Same thing if I want to install OTB_USE_MUPARSER and OTB_USE_6S I add -DOT_USE_… command?

Thank you,

François

Yes !

(there is a missing space after -DOTB_USE_OPENGL here)

Cédric

Hello Cédric,

Thank you.
However, I want to install other modules but it returns me an error (line 76).nmake_install_error.txt (44.1 KB)
I launch this cmake configuration code:
cmake C:/OTB/otb_build -G"NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\OTB\otb_build\install -DCMAKE_PREFIX_PATH=C:\OTB\OTB-7.1.0-Win64 -DCMAKE_CXX_FLAGS:STRING="/DTHROW_QCRITICAL=0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc" -DOTB_USE_QT=ON -DOTB_USE_QWT=ON -DOTB_USE_GLEW=ON -DOTB_USE_OPENGL=ON -DModule_OTBTemporalGapFilling=ON -DModule_OTBPhenology=ON -DModule_OTBBioVars=ON -DOTB_USE_GSL=ON -DCMAKE_BUILD_TYPE=Release -DOTB_USE_OPENCV=ON -DOTB_USE_MUPARSER=ON -DOTB_USE_MUPARSERX=ON -DOTB_USE_6S=ON -DOTB_USE_LIBKML=ON -DOTB_USE_CURL=ON
Do i need libkml or is this library installed by default?

Thanks,

François

Hello Cédric,

I have an error with this command line:
cmake C:/OTB/otb_build -G"NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\OTB\otb_build\install -DCMAKE_PREFIX_PATH=C:\OTB\OTB-7.1.0-Win64 -DCMAKE_CXX_FLAGS:STRING="/DTHROW_QCRITICAL=0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc" -DOTB_USE_QT=ON -DOTB_USE_QWT=ON -DOTB_USE_GLEW=ON -DOTB_USE_OPENGL=ON -DModule_OTBTemporalGapFilling=ON -DModule_OTBPhenology=ON -DModule_OTBBioVars=ON -DOTB_USE_GSL=ON -DCMAKE_BUILD_TYPE=Release -DOTB_USE_OPENCV=ON -DOTB_USE_MUPARSER=ON -DOTB_USE_MUPARSERX=ON -DOTB_USE_6S=ON -DOTB_USE_LIBKML=OFF -DOTB_USE_CURL=ON

Then I run nmake install .

It returns me this error (line 280) ! nnmake_otbbiovars_new_error.txt (25.1 KB)
I don’t understand why it returns this error while I didn’t get it during the first compilation?
${OTBApplicationEngine_LIBRARIES} is still present in the app/CMakeLists.txt of OTBBIOVars.

Thanks

François