Fatal error during graphic initialization

Try to build the samples in: %CASROOT%/samples/mfc. The following steps have been done:
1. run env.bat in %CASROOT%/samples/mfc;
2. run Run_MSVC in %CASROOT%/samples/mfc; [=>All-vc8 lauched]
Then the error "Fatal error during graphic initialization" comes out. According to the forum suggestion, do
3. SET CSF_GraphicShr=%CASROOT%\ros\win32\vc8\bin\TKOpenGl.dll.

Then still got the fatal error. Please help!!!!!!!!!!!!!

lovepipy's picture

By the way, my own application based on OCCT has no the fatal error after I set CSF_GraphicShr to %CASROOT%\ros\win32\vc8\bin\TKOpenGl.dll.

sergey zaritchny's picture

Hi,
Check, please environment variable CASROOT definition.
Probably it is not defined.
Regards

mything's picture

I do not think so.
I think it do not have any relevant for environment values.

because it can compile may OS and vc version.

I have same problems like this. but v8 mode is running and v10 mode is not.

Ausekar Shashikant R's picture

Hi sergey zaritchny
I have successfully build the solidCAD project in VC9 on windows 7 for creating simple solids using open cascade, but facing error in debugging as"Fatal error during graphics initialization". I have set "CSF_GraphicShr" variable 'C:\OpenCASCADE6.5.4\ros\win32\vc9\bin\TKOpenGl.dll' as per forum guide. still problem not solved pls. rpl if you have any idea

Thanks & Regards
Shashikant

mything's picture

this example use env value to set each compiler ver and os

so it need 3 major environment value.

EXEDIR -> it is bin directory. ex) ---Win32/vc10/bind
LIBDIR -> lib directory. ex) ---Win32/vc10/libd
CSF_GraphicShr -> maybe inside invoked DLL. ex) Win32/vc10/bind/TkOpengl.dll

and . EXEDIR and LIBDIR used to set path.
ex) SET PATH = %LIBDIR%,%BIN_DIR%;%PATH%

you donot need to check all over the environment value.

JUST SEE RUN.BAT.. THAT'S ALL

冯 军's picture

still have the problem.

Heinz R.'s picture

Hello Jun,

I am a beginner too, had the same trouble and the setting of the CSF_GraphicShr doesn't work whatever I do.

So I rebuilded first the samples with my OS (Win 7) and Visual Studio 2008 (VC9) in win32-Debug-mode by starting the Batch File Run_MSVC.bat in the installation folder, in my case : C:\OpenCASCADE\samples\mfc.

The samples were rebuilded fine, I controlled it by looking in the folders, for my case :
C:\OpenCASCADE\samples\mfc\mfcsample\adm\win\vc9 etc.

After that I tried to start one of these samples in the development enviroment of Visual Studio 2010
and I got the message: Fatal error during graphic initialisation.

So I tried another way by using the Batch file Run.bat (in the same folder like the above mentioned Batch
file Run_MSCV.bat) from the command line of my OS with the options and the name of the favoured example, in my case the Viewer3d :

run vc9 win32 Debug Viewer3d

and the sample Viewer3d startet without the above mentioned Message: Fatal error during graphic initialisation

- vc 9 stands for Visual Studio 2008 or Visual C++ 2008, in your case you have to write vc10

I always started the Batch Files from the command line and did not closed the command line while working.

The first steps of using OCC are very hard because of setting up the system, but if you follow the documetation carefully,study und use the batch files in the installation folder, you will have sucess.

Best regards and best of luck

Heinz R.'s picture

As an addition to the my first input above I tried to run the mfc-samples of OCC 6.5.0 on another pc with Windows XP3 and Visual Studio 2008.

Although I did it in the same way as described above I got again the failure:
"Fatal error during graphic initialisation"
when I tried to run the batch file with "run vc9 win32 Debug Viewer3d".

I tried set the enviroment CSF_GraphicShr again in several ways, but it didn't work.

For my opinion the setting of the path in which the compiled file TKOpenGl.dll is located is for runnimg the samples also very important.

So I change the batch file run.bat in the my folder C:\OpenCASCADE6.5.0\samples\mfc in this way:

................

IF not "%CASDEB%" EQU "" (
SET EXEDIR=%~dp0%OS_TYPE%\%VCVER%\bind
SET LIBDIR=%~dp0%OS_TYPE%\%VCVER%\libd
SET CSF_GraphicShr=%CASROOT%\%OS_TYPE%\%VCVER%\bind\TKOpenGl.dll
rem add in !!!!! :
SET Path=%CASROOT%\%OS_TYPE%\%VCVER%\bind\TKOpenGl.dll,%path%
) else (
SET EXEDIR=%~dp0%OS_TYPE%\%VCVER%\bin
SET LIBDIR=%~dp0%OS_TYPE%\%VCVER%\lib
SET CSF_GraphicShr=%CASROOT%\%OS_TYPE%\%VCVER%\bin\TKOpenGl.dll
rem add in !!!!! :
SET Path=%CASROOT%\%OS_TYPE%\%VCVER%\bin\TKOpenGl.dll,%path%
)
.................

After that I could start the example viewer3d from the commandline with:

" run vc9 win32 Debug Viewer3d "

and it works pretty well.

Maybe, these remarks will help you.

冯 军's picture

Hello hinzman, thank you so much for the detailed information. I will try and let you know.

Nitin's picture

Hi Hinzman,

I am a beginner in OCCT and I was trying to run the Geometry tutorial. I had the error "Fatal error during graphic initialisation"
So I followed the steps that you mentioned in your earlier post.
Now it gives me an error "C:\Programme\OpenCASCADE6.5.0\samples\mfc\win32\vc8\bind\Geometry.exe is not a valid Win32 application"

How should I resolve this error. I am using Win32 XP Sp3.

Ausekar Shashikant R's picture

Hello hinzman

I am new with open CASCADE, trying to build a simple mfc prog in vc9 on windows7 for cube, cylinder modeling. got error after successfully building prog. "fatal error in graphics initialization" ...

what is the reason for this.. rpl.

Thanks & Regards,
shashikant.

llkojnjhfy's picture

Although I did it in the same way as described above I got again the failure:
"Fatal error during graphic initialisation"
when I tried to run the batch file with "run vc9 win32 Debug Viewer3d".[URL=http://www.fakebagsok.com]fake designer bag[/URL]

TW Hsu's picture

I had the same issue and solved it. Hopefully this note would help you.
When you encounter "Fatal error during graphic initialization", it is an error on loading TKOpenGl.dll.
First, make sure that the environment variable CSF_GraphicShr is defined correctly. In the debug mode, you should see something like:

Loaded 'C:\OpenCASCADE6.5.2\ros\win32\vc9\bind\TKOpenGl.dll', Symbols loaded.

Ok, it is loaded; but still the same error. Well, TKOpenGl.dll depends on other dlls; some of the dlls cannot be loaded then. Use Dependency Walker (http://www.dependencywalker.com/) to verify its dll dependency. Fix the environment variable PATH to locate the missing dlls. Good luck!

Ben Schaeffer's picture

I have the same problem under windows 7 64-bit.

TKOpenGl.dll depends on the other DLLs like GPSVC.DLL which is 64 bit I believe. What's wrong with having OpenCascade the examples that are statically linked and do not use DLLs? I'm spending hours being really unproductive here.

Ausekar Shashikant R's picture

Hi TW Hsu
I have successfully build the solidCAD project in VC9 on windows 7 for creating simple solids using open cascade, but facing error in debugging as"Fatal error during graphics initialization". I have set "CSF_GraphicShr" variable 'C:\OpenCASCADE6.5.4\ros\win32\vc9\bin\TKOpenGl.dll' as per forum guide. still problem not solved pls. rpl if you have any idea. It is neccessary to run.bat file..???

Thanks & Regards
Shashikant

Forum supervisor's picture

Dear Ausekar Shashikant,
You should take into account that environment definition may change time to time(at least environment of OCCT654 differs from environment of OCCT652).
The environment of the last release (OCCT654) is entirely defined by set of scripts custom.bat and env.bat.
Therefore your starting procedures as for msvc as for run.bat should correctly use the last ones.
At least you may check it with Dependency Walker.
Regards

Tushar Suradkar's picture

TW Hsu has pointed out the solution correctly. Using the Dependency Walker, open the TKOpenGl.dll and restore all required file except the DCOMP.dll and API_MS-WIN-CORE which may be ignored. This fixed the issue. Many thanks to TW Hsu !!