Building provided Qt sample on OpenCascade 6.9.0

Recently I've compiled OpenCascade from sources using CMake, using only mandatory packages (tcl/tk 8.5, freetype 2.4.9) on Debian Wheezy 7.8. Draw Test Harness samples are working, now I would like to try some C++ samples (because I have to focus on C++).
I've noticed that there is a Qt sample and I would like to compile it using qmake 4.8.2.

Before running in Tutorial, there are some things that should be done before (maybe this will be helpful to others, newcomers like me):
1. edit and provide the path where occt is installed to CASROOT; QTDIR can be equal to, for example, "/usr"
2. edit and provide this line: export SAMPLESROOT=${aSamplePath}/../
otherwise you will get a warning that /Common/src/*.cxx etc. files can not be found. Note that this only applies if you haven't changed the sample directory structure.

After running, I get some errors:
In file included from ../Common/src/View.cxx:34:0:
/usr/include/X11/Xmu/StdCmap.h: At global scope:
/usr/include/X11/Xmu/StdCmap.h:39:1: error: ‘Status’ does not name a type

This happens because at some point Status is overridden and defined as something else, or just undefined. Changing the order of includes in View.cxx helps a bit (for example: first X11 includes, than Qt, than occt). But, there are another problems similar to this one, just with another names.

Has someone succeeded in compiling this Qt sample?

Any advice would be helpful. Thank you in advance.

Kind regards,

Mladen Banovic's picture

After some modifications, I've managed the Qt sample to work on my system, so here is the solution.

As I wrote, View.cxx has to be modified because there are conflicts in the header files. Changing include order and using macro undef helped to solve the problem. Working View.cxx is in the attachment.

Another thing I had to do is to modify file. Otherwise, compiler could't find the libraries to be linked.

Here is my LIBS definition for (just edit the paths according to your environment):

LIBS += -L/home/OpenCascade/occt-install/lin64/gcc/lib \
-Wl,--rpath -Wl,/home/OpenCascade/occt-install/lin64/gcc/lib \
-lTKernel -lPTKernel -lTKMath -lTKService -lTKV3d -lTKOpenGl \
-lTKSTEPBase -lTKShapeSchema -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
-lTKXSBase -lTKPShape -lTKShHealing -lTKHLR -lTKTopAlgo -lTKMesh -lTKPrim \
-lTKCDF -lTKBool -lTKBO -lTKFillet -lTKOffset

Although Qt sample now works, I don't like the modifications that have to be done on View.cxx, perhaps this could be done in another way so there are no conflicts in the header files.


Michael T's picture

Thank you Mladen!

I had exactly (or almost) your problem and thanks to your View.cxx file I have now managed to build the Qt example with cmake!

I am working on an OpenSUSE 13.2 box and have  OpenCascade 6.9.0 installed.

As you, I am a bit frustrated over the problems building opencascade examples on Linux (together with Qt). Since we are not alone I suspect this may be a general problem? I just feel that needing to set the include order right and to use #undef macros in our code is not right! But if this is the only way I gladly accept it for now! :-)

One question to you: How did you manage to find all the right #undef? It seems to me that you had to do some serious digging!

Once again, thank you for your work!



Mladen Banovic's picture

So I am not the only one facing this issue, nice to see that. :) I also don't like this solution, but seems it is the only one for now.

For finding the right #undef, you have to do some serious digging. The goal is to have a look at preprocessor output of the file that is being compiled - View.cxx. To do this, you have to add a flag -E in your g++ call, for example: g++ -E View.i View.cxx ... Then, inside View.i, you can see everything what compiler sees (all includes). Than you can try to track your issues there and to see all files that are included in the compilation process, but it is not easy to read and can be very time consuming...