OpendTect development on MS Windows

Visual Studio 2017 | CMake | Building the Tutorial plugin | Building your own plugin | Building OpendTect

Visual Studio 2017

OpendTect 6.4 is built with Visual Studio 2017, and it also supports Visual Studio 2017 Community Edition. The Community Edition can be downloaded from Microsoft's official web site

CMake

CMake is a cross-platform tool that takes care of generating system-dependent project files. It can be downloaded from CMake's web site.

Building the Tutorial plugin

To get the whole process going we will first build the Tutorial plugin. This will set up the Visual studio project we need, and the plugin itself can be very useful for understanding several important OpendTect programming concepts.

The basic idea is like this, first you have your OpendTect installation folder, where you actually download the developers package from the installation manager, then you have to create your own plugin development environment which should be outside the OpendTect installation folder, the reason for this is of course that these two environments should be different, and you do not want to mix up your own plugin development work along with your software installation.

  • Install developers package from the installation manager.
  • start OpendTect and then from Utilities-Tools-Create Devel Environment launch the create work environment tool. There specify a folder (WORK) to copy the plugin building material into. That can be any folder with names like "C:\WORK" or "D:\Tools\ODWork" but Do Not Put It In The OpendTect Installation Folder. After creation, this will be where you do your work, so choose a stable, backed-up directory there.
  • Now start CMake (desktop item or its Windows start menu). Select the WORK directory you just created, and put it in both the "source" and "output". Then press the 'Configure' button.
  • Configure will probably fail due to missing OpendTect-DIR. This can be specified, choose the OpendTect installation directory there (e.g C:\Program files\OpendTect\6.4.0). Now press configure again.
  • Some virus scanners like AVG will ring the alarm bells, and this can make the whole process fail. This is because CMake tries to link a program to test the system setup. To get this right, I had to disable my virus scanner (AVG).
  • When you get 'Configuring done' you may still have a few red lines in the variables box. Don't worry: things should be ready and you can press the 'Generate' button. You can close CMake and switch your anti-virus back on.

CMake has now generated the projects and the solution file for the plugins. Now you can start Visual studio and load the OpendTect_Tutorial_Plugin.sln which has just been created by CMake, in your WORK directory.
Then, to build the plugins: simply right-click on 'Tut' and 'uiTut' and do 'Build' for each. That's all.

Debugging the Tutorial plugin

Open the plugin solution in Visual Studio, and right-click on the solution item, and open the solution properties window. Here you can specify the debug source file location, so in your case add the location of the OpendTect source files which are installed by the installation manager, i.e. C:\Program Files\OpendTect\6.4. Now select the "od_main" project which is a launcher project to launch od_main debug executable that comes with the developers package. Right click on this project and set to "Set as startup project". When you press F5 for debugging this project will be started. Ignore if you see any Visual studio warnings. The OpendTect main program, od_main.exe will be launched.

From Utilities-Installation-Plugins OpendTect try to load your plugin by browsing to the WORK(D:\WORK)\bin\win64\Debug folder. To debug something, just set a break point in the code. So when the control comes to the break-point it will stop there and you can debug your code. You can also browse into OpendTect source files if you have specified the OpendTect source file location is the solution properties as mentioned above

Building your own plugin

If you want to create your own plugin, you have to create a folder with the name of your plugin inside your plugin development environment and add the source files and CMakeLists.txt to this folder as done in the tutorial plugins. Procedure:

  • Exit Visual Studio.
  • Create the folder for your plugin project and rename it with the name of your plugin e.g 'My_Inversion'.
  • Add "my_inversion_pi.cc" along with other source files in this folder.
  • Create a CMakeLists.txt file inside this folder and add the entries for all your source files to it.
  • Edit the ODWork\CMakeLists.txt, add 'My_Inversion' to the list of projects. Currently you will see both Tut and uiTut in this list.
  • Now configure CMake just like you configured before. I didn't have to disable my virus scanning anymore, but you may have to do this.
  • If you manage to make the projects and successfully build them, then start the od_main project again and load the new plugin DLL from ODWork\bin\(win32/64)\Debug in to OpendTect. If all goes well you will be able to debug your code by putting a break point in your source files.

Debugging your own plugin

The process is exactly similar as described above, 1)start Visual Studio 2) build the plugin 3) start 'od_main' project 4) load and debug your plugin.

Distributing your own plugins

Your plugin can be distributed with the new installation manager and OpendTect download site. You have to ship the plugin binaries and documentation to opendtect.org, where it will be available for download.

Building OpendTect (only for die hards)

To build OpendTect from source you need to pull the source code from https://github.com/OpendTect/OpendTect. Then build the solution with CMake. In this case launch CMake and browse to your OpendTect source folder and start configuring and generating from CMake. CMake will prompt for Qt and OpenSceneGraph directory location, select them from CMake itself and continue. Once the projects and solution are generated you can start building OpendTect.

Qt

A Qt installation is only necessary when you want to build a plugin which is directly dependent on Qt or you want to build OpendTect from scratch. Download Windows Qt package from the Qt website.

OpenSceneGraph

A full OpenSceneGraph installation is only necessary when you want to build a plugin which is directly dependent on OpenSceneGraph or if you want to build OpendTect from scratch. Download an OpenSceneGraph installation, or get the source code from OpenSceneGraph repositories and build yourself using Visual Studio.



Index | Overview | Rules | Plugins | Attributes | UNIX | opendtect.org