OCC Tutorial 01 -Setting up OpenCascade in Linux

Installing

Before getting started in OpenCascade, you need to install the libraries. Windows have binaries provided, but for Linux, you need to compile from source.

I wrestled for a while with the official source from the OpenCascade site, with very little success when it came to having it run C++ code. But the Community edition worked very easily.

First off, Head over too the GitHub page and download the latest release. As of writing this, the most up to date version is 0.17.1.

I can reiterate what they’ve said, but it’s likely best to read the BUILD.Unix.md file in the source root directory to get a full list of install instructions.

Testing the Install

From there you can can go into the $INSTALL_DIR/bin/directory and run DRAWEXE too see the test harness.

You can find *.tcl files to run tests under source (Source Location)/samples/tcl/

Screenshot from 2016-03-07 15-58-39

Setting Up OCC for Codelite

I use codelite to develop C++ apps, simply because it’s cross platform and easier to work with than CodeBlocks. That said, you should be able to run this on any IDE.

Compiler Options

Compiler Flags

First, set up the compiler options. Too embed it into a wxWidget Control, you will also need to add flags for GTK 2.0 (at least).

-g;-O0;-Wall;
$(shell wx-config --cxxflags --unicode=yes --debug=yes);
$(shell pkg-config --libs --cflags gtk+-2.0);
$(shell pkg-config --libs --cflags glib-2.0);

These need to be added to both the C++ and C compiler Options.

Include Libraries for Compiler

From there, the include libraries, assuming you’ve used the default options, are

/usr/local/include/oce
/usr/include/gtk-2.0

 

Linker Options

Depending on your install and what sort of install you’re using

$(shell wx-config --libs --debug);$(shell pkg-config --libs --cflags gtk+-2.0);$(shell pkg-config --libs --cflags glib-2.0);-lTKernel;-lTKMath;-lTKBRep;-lTKTopAlgo;-lTKPrim;-lTKBO;-lTKOffset;-lTKService;-lTKV3d;-lTKOpenGl;-lTKFillet

The first handful of lines are simply for the wxWidgets library, the last few are for the GTK config and then finally the OCE/OCC libraries are linked at the very end.

Libraries Search Path

You need to then add

/usr/local/lib

to the Libraries Search Path.

Libraries

Add the following libraries to the Libraries section in your Build Settings.

X11
libTKService.so
libTKernel.so
libTKMath.so
libTKBRep.so
libTKV3d.so
libTKOpenGl.so
libTKTopAlgo.so

In the next tutorial, I’ll go over how to embed a OpenCascade Window into  wxWidgets Control.


					
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s