Mixing C++ and python code in your omegalib application

Capture

In omegalib, Applications can be developed as standalone executables in C++ or as scripts in Python. Omegalib also supports mixed native/script applications with user-defined C++ modules that can be exposed to Python through a simple declarative interface. When needed you can build part of your program using C++ and turn that into a python module integrating the omegalib API. You can then import this module into python using import moduleName and use some of its exposed interfaces.

Assuming you have an omegalib installation on our machine, you can find it using the CMake command find_package(Omegalib). The command will add a new variable to your cmake configuration asking for the path to the omegalib build dir. After setting that, you will have a set of standard variables defined (OMEGA_INCLUDE_DIRS, OMEGA_LIB, OMEGA_TOOLKIT_LIB, CYCLOPS_LIB) that you can use to set header files and libraries for your project).

After building, the project will output a .so or .pyd file (depending on the platform). You will be able to import this module into a python omegalib script launcher through orun. C++ classes and methods are exposed using a module declaration section in your source file. The module declaration lists all the classes and methods you want to expose, together with some minimal information about how they work.

Red more about mixed-code programming for omegalib here

Comments

Popular posts from this blog

Parallel Gaussian Elimination Using MPI

Parallel Beam Tracing and Visualization of 200 Million Sonar Points

Flickering 2D transform elements in Chrome: a simple fix