How to re-build OpenCascade 6.3 for Visual Studio 2005
I’ve had success re-compiling OpenCascade 6.3 from source using Visual Studio 2005. In the process I have also been able to re-build all of the samples: Qt, Java, MFC and the tutorial code.
I thought I would share the details of the process. (My apologies if I’m repeating a similar post by another forum member, but I hope that other users may find it useful?)
List of Dependencies (You’ll need these installed before you start anything):
-Visual Studio with SP1
-JAVA JDK (not JRE)
-Tcl, Tk and Tix
You would also do well to install (or check that you’ve already got):
-Microsoft .NET framework 2.0
-Microsoft Windows SDK
-Visual Studio with Service Pack 1 – SP1 available as a download from Microsoft.
-JAVA JDK (don’t just install the JRE if you want the Java sample to build - the JDK comes with the JRE anyway) – I used “jdk-6u7-windows-i586-p.exe”.
-Tcl, Tk and Tix should all be installed to the same directory – I used c:\Tcl Details to follow below.
-fltk – this can be compiled from source, see below.
-Qt4 – Get the .exe not just the source version. I used “qt-win-opensource-4.4.3-mingw.exe”. This version is more useful when building your own Qt projects. (Qt isn’t strictly necessary if you plan to develop all your GUI code with MFC, but it’s needed for building some of the samples and allows you to develop a cross-platform GUI so you’re not limited just to Windows releases. Allow and extra 3-4 hours for building this, but you can start it off and walk away so don’t worry.)
Now taking each one of these in turn. First the easy ones:
-Visual Studio SP1,
-Microsoft .NET framework 2.0, and
-Microsoft Windows SDK.
Google “Microsoft Visual C++ 2005 SP1 Redistributable Package”. Download & install.
And then “Microsoft .NET Framework Version 2.0”. Download & install.
Lastly, Google:“Microsoft Windows SDK”. Download & install. (I used “Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5” and even though I’m on an XP SP3 system, this caused no problems.)
You can Google this again, but you’ll find it’s known as “Java SE Development Kit (JDK) 6 Update 10”
Important note: You should install this to a directory that doesn’t contain spaces in the filename (i.e. DO NOT INSTALL IN C:\Program Files\...”
Ensure that you have an environment variable set for this location once it’s installed. (Add this if you can’t find it) Right-Click MyComputer>Properties>Advanced>Environment Variables>New (system variable)> “JAVAHOME” C:\Progra~1\Java\jdk1.6.0_07. (or where ever you installed it)
You’ll notice that I DID make the mistake of putting it in the Program Files! – It’s recoverable if you enter it as I have (using “Progra~1”).
-Tcl, Tk and Tix
Unless you’re feeling VERY brave, and you want to compile these from source, you’ll find files on the web that allow you to install these from windows exe’s. It’s painless this way. I wouldn’t recommend compiling from source.
Tcl and Tk come together and are available from a website called “Active State” (http://www.activestate.com/Products/activetcl/index.mhtml). You want “ActiveTcl”. I installed this to C:\Tcl What ever destination you choose, be sure to put Tix in there as well when you get it.
I found an executable for Tix on SourceForge by looking for ”Tix Library for Tcl/Tk” (http://sourceforge.net/project/showfiles.php?group_id=19412 ). Or you could Google the version I found “tix-8.2.0b1-setup.exe”. Install this AFTER Tcl/Tk and, as mentioned above, install to the same folder - therefore, I used C:\Tcl
-fltk (you CAN build this from source)
Regarding fltk, there seems to be two versions of source e.g. 1.3.x.x and 2.x.x.x available at any one time. Get the lower number version. This should have a folder named VC2005 (when you unpack it) and means that you can build it yourself. (You can't build the higher numbered version it seems, as it doesn't have a VS2005 project type). I unpacked it to D:\fltk-1.3.x-r6350\
Load the FLTK solution in Visual Studio and go to Tools > Options > Projects and Solutions > VC++Directories and under "Show directories for:" select "Include files". Select the top directory listed and click the folder icon to insert a new line at the top; enter “D:\fltk-1.3.x-r6350\fltk-1.3.x-r6350”. Now select "Library files", select the top directory listed and click the folder icon to insert a new line at the top; enter “D:\fltk-1.3.x-r6350\fltk-1.3.x-r6350\lib”. Build the solution (F7) and start it (CONTROL-F5). If you are successful, CubeViewd should execute.
I used the .exe version of Qt (qt-win-opensource-4.4.3-mingw.exe). It comes with the mingw complier that can be useful when you build you own Qt projects (even if you’re working in VS 2005). So, make sure you get/tick the mingw compiler during the install process.
Go back and “set” some more environment variables. Right-Click MyComputer>Properties>Advanced>Environment Variables>New (system variable)>
Add these two:
(or whatever version\location you have). Also add this
You’re going to build Qt with VS2005, so now load Visual Studio. Then : Tools> Visual Studio 2005 Command Prompt>
Move to the place where you installed Qt e.g. “cd c:\qt\4.4.3\” (in my case)
Type “configure” . Wait a bit.
Type “nmake”. Walk away for a few hours.
P.S. Check P Dolbey’s post on this page for a more compressive guidance if you run into problems:
Also, now it has built/compiled, make sure that you go back in to your environment variables (as above) and set a couple more now. Edit the PATH setting and add to your existing list “C:\Qt\4.4.3\bin;C:\Qt\4.4.3\lib”; or whatever your path to Qt is - the crucial part is to have the PATH set to look at the “bin” and “lib” folders of Qt.
That’s pretty much it for the dependencies. It will have taken you half-a-day or more, mainly caused by waiting for Qt to compile. Now you can start to re-build OpenCasacde 6.3.
IMPORTANT NOTE: This is where my guidance varies. I’d done all this myself and carried on in that way I am about to describe, only to find that I couldn’t build the samples! Specifically, some of the folders were missing from the “source” download of OpenCascade. Never-the-less I have managed to get all of the rest of OpenCascade installed (dll’s and lib’s).
So, strangely…I’m going to advise that, even though you’re now about to build OpenCascade from source, I would actually recommend you to get the self-installer “OpenCASCADE_win32.exe” the RAR-Self Executable!! Install it, and then re-build it yourself for VS2005! At least you will have the re-assurance of all the libraries being built for Visual Studio 2005, plus all the alterations you’re about to make to Visual Studio should mean that compiling the samples (and your own code;-) is much easier.
The official advice is to make sure you un-install any previous version of OpenCascade. The OpenCascade self-installer should then run ok because you’ve already got the Java JRE as part of the JDK.
So, you’ve got all the dependencies installed in their respective directories. You’ve also installed OpenCascade6.3 with the self installer. This should have automatically added other environment variables for you as well. Whilst not absolutely essential, we’re going to change some of these environment variables to reflect the dependencies that we’ve just installed. This way, Visual Studio will make use of them as it compiles OpenCascade instead of the ones that it has placed in the “OpenCascade\3rdparty\win32” folder. So, it’s “Right-Click MyComputer>Properties>Advanced>Environment Variables>” again. Make these changes (alter appropriately if you’ve installed the dependencies to other folders of course :-)
And you should already see entries for these:
And, in addition to all the other PATH entries you have, your path should have these entries:
If not, edit to make sure you have all these
Now, go into Visual Studio 2005. There are changes to be in made here: “Tools>Options>Projects and solutions>VC++ Directories”
We need to make changes to these 3 areas in “Show directories for”
1 -The executable files
2 -The include files
3 -The Library files
I’m going to cut-and-paste from what I have listed. Once again, you’ll need to change these if you’ve installed the dependencies to different directories – for example I’ve installed my OpenCascade and fltk on my D:drive.
1 – The executable files
2 – The include files
3 -The Library files
Finally we’re ready to build!
There is a specific order.
You build the packages in this order and, before you progress onto the next package, make sure the last one has build with no errors (don’t worry about seeing warnings though, it’s just errors=0 that you want to see). Here’s where you should load the solution files from:
This is the correct build order =
1- Foundation Classes (file FoundationClasses.*)
2- Modeling Data (file ModelingData.*)
3- Modeling Algorithms (file ModelingAlgorithms.*)
4- Visualization (file Visualization.*)
5- Application Framework (file ApplicationFramework.*)
6- Data Exchange (file DataExchange.*)
7- Draw (file Draw.*)
8- WOK (file WOK.*)
9- Wrappers (file Wrappers.*)
Where * is .sln for VC++8.0 (VS2005)
That’s pretty much it! Each time, click on “all” and build with F7. There is one problem that you will occasionally come across though. It’s not a big problem, but these solution files were linked by OpenCascade to expect files called “tcl84.lib” and “tk84.lib”. If, like me, you’ve got a later version of Tcl/Tk you will have to make changes when you find build problems….
Specifically, when building “Draw” in Visual Studio,
required me to right click on each of them in “Solution Explorer” then: >Properties> Linker>Input>AdditionalDependencies and then edit the list. Just change the entries for “tcl84.lib” and “tk84.lib” to “tcl85.lib” and “tk85.lib”. This is because these are the correct file names as found in C:\Tcl\lib. If you’ve got an even later version of tcl and tk then use the filenames in there but, at the time of writing, these are the versions that come from the ActiveTcl.exe installer (above). There are 7 or 8 identical changes to make when you try and build WOK too. You’ll be used to it by then ;-)
That should be it :-)
When I checked the OpenCascade folders, I had 98 new library files in \OpenCASCADE6.3.0\ros\win32\lib - all freshly built, therefore recently dated. And 95 .dll’s in the \OpenCASCADE6.3.0\ros\win32\bin folder with 3 .exe’s (draw.exe, wokprocess.exe, woksh.exe) all recently dated too.
I’d leave myself half a day to do all this if I were to do it again….a full day if I was building Qt as part of the process.
I then went on to successfully build the samples without too many problems, and if other users are interested, I can post the process for rebuilding those? Perhaps in another post though (?) as I realise this is already a very long entry.