Writing OTB modules with Visual Studio IDE

From OTBWiki
Revision as of 14:30, 11 May 2017 by Rashadkm (Talk | contribs) (Run HelloWorld.exe)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

For users , who does not have a visual studio 2015 installed, or ot using a windows 7 x64 or higher can skip this page. The rest of read is zero interest to you.

Note: C++ components are optional. so please pay attention when installing VS 2015. We use community edition. If you have professional or enterprise edition. The rest of instruction will work for you as well.

This page covers writing OTB modules with Visual Studio IDE, if you use CMake with a different CMake generator such as Ninja, JOM, NMake. See Writing OTB modules with XDK with CMake

Building OTB and all it depends on your own

If you want to start building from ZLIB to GDAL to ITK, OSSIM and OTB. Well, you are in the wrong page. checkout HOWTO on OTB superbuild.

Building only OTB

If you want to just build OTB and need a shortcut to setup all "N" required libraries for OTB. Checkout this wiki page on OTB_development_on_Windows.

Writing modules and or applications using OTB

[This is now available only for OTB 5.10.1 and OTB 6.0 windows x64. Adding it for future versions of OTB is not confirmed yet. ]

You don't use CMake, git bash, cmd prompt, or anything. Only tool we expect you to have a unzip tool such as 7zip other than VS2015 IDE


You can write your own modules, remote modules, applications using OTB in windows with MSVC 2015.

Windows support for OTB has been improved a lot since last couple of releases. Now we are going to go one more level up for our windows users.

What will that be?

start writing your first OTB application in 5 minutes!

First you need to download and extract OTB XDK. We use 7zip installer but any other unzip tool should work.

https://www.orfeo-toolbox.org//packages/xdk/OTB-5.10/OTB-5.10.1-xdk-win64.zip

Steps

Open Visual Studio 2015 IDE with start_devenv.bat

  • start_devenv.bat script is located in OTB-5.10.1-xdk-win64 folder.


Create new project [ Ctrl + Shift + N ]

  • File -> New -> Project..

There is now a project type called "OTB Project". select that. In the bottom panel. you can change name and project and solution. see image below.

Step 2.png

Add source file(s) [ Ctrl + Shift + A ]

  • Solutions Explorer (Right panel) -> Source Files (Right click) -> New -> Item..

Msvc Step 3.png


Select build type and architecture

Only release with x64 is supported for now. follow higlighted text

Msvc Step 4.png

Start writing your code!.

Build [ Ctrl+ Shift + B ]

  • Build -> Build Solution


See the output of build window on bottom. It says sample helloworld.exe is created.

output window

Run HelloWorld.exe

Here is how to start helloworld.exe.

When you launched start_devenv.bat, it opened visual studio IDE and opened a windows command prompt.

If you closed it, you can save your work and launch start_devenv.bat again!

In this command prompt, you can verify PATH and other things are in order. For me the PATH variable looks like something below

echo %PATH%
C:\otbdev\OTB-5.10.1-xdk-win64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPo
werShell\v1.0\;C:\Tools\CMake-3.5.2\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Tools\Gi
t-2.9.0\cmd;C:\Tools\Git-2.9.0\bin

See the "C:\otbdev\OTB-5.10.1-xdk-win64\bin" in PATH

You can now navigate to your project directory and run HelloWorld.exe. You can see your project executable path from output window screenshot in last section.

cd c:\otbdev\vsproject\HelloWorld\x64\Release
HelloWorld.exe

That's it!. you now have all features of visual studio IDE and you can continue rest of your development on OTB.

Summary

We look forward all your contribution into OTB soon!.

You need to write CMakeLists.txt and otb-module*.cmake files for your project if you want to push changes to upstream.

We already have a HOWTO on writing remote modules. Please have a look at that.

This page is meant to provide better support for Visual Studio users.

More importantly, your code, I mean your efficient code is your principal contribution to project. We thrive to help you write those part without trouble as possible.

Other stuff such as cmake scripts, otb-module etc which I comes second to that. If you don't have any algorithm or application, having those files is of zero value. but the opposite is not quite true. right?

Finally having this guide will make OTB development on windows easy and fun.

Feel free to report your feedback, comments, suggestions, bugs, on otb-developers group or via bugs.orfeo-toolbox.org