Trouble compiling Qt Opencascade

I have been trying to get the viewer of open cascade to recompile using Qt4, and I did notice code that Peter Dolbey created to do this in windows, but I have been unable to get his version to compile and run.

I've been getting linker errors like:

./debug\MakeBottle.o(.rdata$_ZTV16BRepAlgoAPI_Fuse[vtable for BRepAlgoAPI_Fuse]+
0x34):C:/OpenCASCADE6.1.0/ros/inc/Adaptor3d_Surface.hxx: undefined reference to
`BRepAlgoAPI_BooleanOperation::HasDeleted() const'

Which lead me to think the problem might be that I need to recompile Opencascade using Visual Studios or Qt first, but I've had trouble even doing that. So it may also be helpful if someone told me how to go about that.

I'm using Window OS, Visual Studios 2005 (though also trying by using Visual Studios 6.0), and Qt4. I also have the latest version of OpenCascade.

P Dolbey's picture

To begin, it looks to me like you've got some confusion in your makefiles - presumably as a consequence of your Qt4/qmake environment. The "MakeBottle.o" reference implies a Unix model, but the include file has a Windows form. My guess is that you've set up the project to run as a MinGW compile, not a VS2005. Assuming you've QtWin'd the Qt open source package (or are using a commercial version) you should be using a QMAKESPEC of "win32-msvc2005". Now if this makes sense - great, otherwise I'll go slower and go one step at a time. There is a known gotcha with the viewer, but you haven't got close to it yet.

Pete

maninred's picture

That makes sense to me. Trying to compile it with VS2005 now, but having trouble getting nmake to compile. Following guides like this site http://wiki.qgis.org/qgiswiki/Building_QT_4_with_Visual_C++_2005 for trying to use Qt with VS2005, the only difference being my directory for Qt 4.1.1 is in my c: drive. I reach the second step, where qconfigure.bat runs fine and then namke runs into errors. My latest attempt reaching these errors while handling qdrawhelper.

...
painting\qdrawhelper_x86.cpp:649: error: `ica' undeclared (first use this functi
on)
painting\qdrawhelper_x86.cpp:649: error: `mmx_0x0080' undeclared (first use this
function)
painting\qdrawhelper_x86.cpp:649: error: `_byte_mul' undeclared (first use this
function)
painting\qdrawhelper_x86.cpp:649: error: `add' undeclared (first use this functi
on)
NMAKE : fatal error U1077: 'C:\MinGW\bin\g++.EXE' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\n
make.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.

Any idea what is going on here? Have yet to find any guide mentioning what to do when nmake fails to compile.

P Dolbey's picture

OK I can see what's going on here. You can tell from the 'C:\MinGW\bin\g++.EXE' line that the makefile is trying to run the MinGW compiler not VS2005.

This won't work if you have patched VS2005 to SP1 - there's a known Microsoft "regression" with templates that breaks Qt4. Microsoft have issued a hotfix for SP1 but this is reportedly difficult to obtain from MS. However if you have SP1'd your VS2005 then try this link it should find the appropriate patch from a "community" resource http://hotfix.xable.net/download/index.php?dir=English/Visual%20Studio%2...

Here's what I do, except I now use drive F: not drive C:. First head off to the TrollTech download site and grab the latest stable Qt 4.2.3. ( or use http://www.trolltech.com/download?target=ftp://ftp.trolltech.com/qt/sour... )

Unzip this 42MB file. I tend to do this into a temp directory then move all the exploded files to a file tree such a C:\Qt\4.2.3 - you want the "configure.exe" at this point of the folder heirarchy.

Now head of to sourceforge and grab the Qtwin patchfile for 4.2.3. Yo want the acs-4.2.3-patch1.zip file (try http://downloads.sourceforge.net/qtwin/acs-4.2.3-patch1.zip?modtime=1173... )

If your feeling confident you could try getting the files for the Qt4.3 beta as well.

Again explode the patch file and copy the tree into the C:\Qt\4.2.3 folder - you want the installpatch42.bat at this point of the heirarchy.

Now IMPORTANT - run a command "cmd.exe" window and cd to "C:\Qt\4.2.3". Type installpatch42 to run the patch file. The required "diffs" will be applied and a "qconfigure.bat" should appear in the same folder. At this point I tend to make a further manual patch to one of the qmake source files, but you only need to do this is you have multiple versions of Visual Studio installed - let me know if this is the case. Also I add some further options into the qconfigure.bat call to configure.exe - again don't worry about these yet.

Now in the command window run your vsvars32.bat batch file to set your VS2005 compilation environment for the command window. Here's the missing step - type "qconfigure msvc2005". This will build Qt for VS2005. Follow all the prompts to build the Qt4 make/qmake system. This takes a couple of minutes.

Now you are ready to build Qt. Type "nmake". This is a now good time to go out for a meal, enjoy a few beers or spend time with the family - it will take several hours to build. You might consider downloading the QSA scripting system - the open source version can be overlaid quite nicely on the eventual Qt4 build but thats another story (and made redundant in Qt4.3 by the addition of QScript - something I wand to investigate for OCC).

When the system has built, I suggest you now set up the following environment variables.

SET QTDIR=C:\Qt\4.2.3
SET QMAKESPEC=win32-msvc2005

and add "C:\Qt\4.2.3\bin" to the PATH variable.

Now you should be able to run the samples, examples etc.

Enjoy

Pete

P Dolbey's picture

Remember to make the environment variables SYTEM not USER in the control panel.

Pete