Step by step instructions to run Open Cascade in Visual Studio

I downloaded
https://dev.opencascade.org/system/files/occt/OCC_7.7.0_release/opencasc...
to
\Downloads\opencascade-7.7.0-vc14-64.exe
I double clicked it to install at
...\OpenCASCADE-7.7.0-vc14-64
I read instructions at
https://dev.opencascade.org/doc/occt-7.7.0/overview/html/index.html#intr...
Environment Variables
To run any Open CASCADE Technology application you need to set the environment variables.
On Windows
You can define the environment variables with env.bat script located in the $CASROOT folder. This script accepts two arguments to be used: the version of Visual Studio (vc12 – vc143) and the architecture (win32 or win64).
WHAT IS THE EXACT COMMAND FOR env.bat? WHERE TO EXECUTE?
The additional environment settings necessary for compiling OCCT libraries and samples by Microsoft Visual Studio can be set using script custom.bat located in the same folder. You might need to edit this script to correct the paths to third-party libraries if they are installed on your system in a non-default location.
WHAT IS THE EXACT COMMAND FOR custom.bat? WHERE TO EXECUTE?
Script msvc.bat can be used with the same arguments for immediate launch of Visual Studio for (re)compiling OCCT.
WHAT IS THE EXACT COMMAND FOR msvc.bat? WHERE TO EXECUTE?
HOW TO PROCEED TO DO "BOTTLE" TUTORIAL IN Visual Studio 2022?

Thanks,
Aik-Siong Koh

A-S Koh's picture

Please help. Thanks.

Dmitrii Pasukhin's picture

You would like to build OCCT or sample? I recommend to build OCCT with CMake instead of genproj.

To build installed version of OCCT you need just to open CMD and exec ".\msvc.bat vc142 win64 release"

Guides for CMake build:

https://dev.opencascade.org/doc/overview/html/build_upgrade__building_oc...

https://www.linkedin.com/pulse/build-occt-guideline-cmake-win-dmitrii-pa...

Best regards, Dmitrii.

A-S Koh's picture

I did the following and got link errors below:
https://dev.opencascade.org/release
https://dev.opencascade.org/system/files/occt/OCC_7.7.0_release/opencasc...
Install to
...\OpenCASCADE-7.7.0-vc14-64
https://dev.opencascade.org/doc/overview/html/build_upgrade__building_oc...
Start CMake GUI
Where is the source code:
Select path to ...\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0
Where to build the binaries:
Select path to ...\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\build
Click/Configure
Click/Generate
In Windows Explorer
DoubleClick
...\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\build\OCCT.sln
In Visual Studio
Click/Local Windows Debugger
Link errors
LNK1104 cannot open file '..\..\win64\vc14\libd\TKDraw.lib' DRAWEXE C:\Users\askoh\OneDrive\askoh\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\build\src\DRAWEXE\LINK 1
I suspect the path '..\..\win64\vc14\libd\TKDraw.lib' is incorrect. How to change that in Visual Studio?

A-S Koh's picture

I also tried to install OCCTOverview and got LINK error below.
https://dev.opencascade.org/doc/overview/html/samples_qt_overview.html
I edited
...\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\samples\qt\OCCTOverview\custom.bat
to contain
set "CASROOT=%~dp0../../.."
set "QTDIR=C:\Qt"
In Windows Command Prompt
cd ...\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\samples\qt\OCCTOverview
.\genproj.bat vc143 win64 Debug
.\msvc.bat vc143 win64 Debug
In Visual Studio
Click/Local Windows Debugger
1>LINK : fatal error LNK1104: cannot open file '...\OpenCASCADE-7.7.0-vc14-64\qt5.11.2-vc14-64\lib\qtmaind.lib'
There is a qtmaind.prl but not qtmaind.lib.
Please help. Thanks.

A-S Koh's picture

Please help.

Dmitrii Pasukhin's picture

Hello, your description is not clear for me at all. I can't get what are you doing. Please load just souce code and build pure source code using 3rd-party from the installed folder.

https://dev.opencascade.org/system/files/occt/OCC_7.7.0_release/opencasc...

Best regards, Dmitrii

A-S Koh's picture

Dmitrii: Thanks for responding. But I really need more steps to make progress. What do I do after extracting the *.tgz file? The readme.txt is not helpful to me. Thanks, Aik-Siong Koh

Dmitrii Pasukhin's picture

In this case, please share what do you want to build. OCCT or samples? When you using my guide for CMake, you need to work only with just source file, not installed files. Please unpack archive and doing everything according to CMake guide. 3rd-party folder it is your installed occt root.

Best regards, Dmitrii.

A-S Koh's picture

I want to learn OCCT so that I can make FreeCAD better.
I use Visual Studio in Windows 11. Not VSCode.
I assume doing the tutorial will be a good start.
...\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\samples\qt\tutorial
Let me know if you think otherwise.
Thanks,
Aik-Siong Koh

A-S Koh's picture

Please help. Thanks.

Andreas Felix Häberle's picture

I do not want to discourage you here, maybe it is a good thing to have a big vision but making FreeCAD better is quite a challenge.

Maybe you already have all things set and I would love to see you succeed.

Me being a new OCCT contributor would start in understanding the test system and find those edge cases from FreeCAD that gives strange results.

Creating testcases to show the issue and help others to fix things in OCCT.

That at least is what I am aming - my focus though is on issues that our build123d community struggles with.

You beeing a SW developper you might find build123d or CadQuery the already better FreeCAD - just saying.

A-S Koh's picture

Thanks for your feedback. I am truly inspired by Elon Musk to try the impossible. There is all to gain and little to lose. He has the "You only live once" attitude.
Right now, I need help from someone to get plain OpenCascade to build in Visual Studio in debug mode. I want to run the tutorials in debug mode.
All the instructions I have been following seem to fail at some point.
Thanks,
Aik-Siong Koh

Dmitrii Pasukhin's picture

Hello, Thank you, I get you issue. But creating a step-by-step guide takes a time. The CMake guide previously looks as enoungh, but as result it is not. Probably we will record a video on our official youtube channel.

But I ask you to try again the next guide CMage Guide

Best regards, Dmitrii.

A-S Koh's picture
Dmitrii Pasukhin's picture

Oh, looks like there is some limitation with connections. Lets check this one CMake GUIDE

But currently I planning to describe step by step build process more deep. But it will be a little later. (new Guide including Samples)

Best regards, Dmitrii.

A-S Koh's picture

Thanks. A good guide will encourage people to participate.

A-S Koh's picture

The new link worked. I was able to Configure and Generate the *.sln.
I doubleclicked on OCCT.sln and Visual Studio is up and running.
As a pure beginner, what do I do next? I would like to debug the tutorials.
Thanks,
Aik-Siong Koh

A-S Koh's picture

I am now able to run the TCL/TK tutorials. I would really like to debug the QT C++ tutorials. Thanks.