For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Minimal library to tesselate a BRep

Gordon Ferguson's picture


I am new to OpenCASCADE. I am trying to build the OpenCASCADE library on Windows. I don't need any graphics as all I'm interested in is a console application that reads a brep file and tesselates it.

Using CMake I managed to configure my build to create static libraries with no graphics support. However, when I build my simple console application - essentially, I declare TopoDS_Shape myShape, BRep_Builder b, then try calling BRepTools::Read (myShape,argv[1],b).

For some reason, when I link the executable I end up with a lot of unresolved symbols - apparently, all of them from the math library: ACos, Log, ATan2, etc.

Can somebody help me out? Maybe I'm missing some header file or I'm not properly building some library.


qa qa's picture

First of all, try to add TKernel library as a dependency. It contains OCCT wrappers to standard functions like you have mentioned.

qa qa

Gordon Ferguson's picture

Hi, and thanks for the reply.

I do have TKernel as a dependency. What I suspected is that there were some pre-compiled headers I needed to include. Not knowing which I basically added a few thousand lines of "include <...hxx>" in my 10-line test program - pretty much all header files in the OpenCASCADE "inc" folder. With that I got it to work.

However, I do get LOTS of warnings when linking. I suspect it is because I built static libraries and I'm building my application on the command line using nmake and I may not have all the proper compilation/linker flags defined.

A typical warning is as follows:

TKTopAlgo.lib(BRepApprox_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfApprox_0.obj) : warning LNK4217: locally defined symbol ?DACTCL_Decompose@@YAHAEAVmath_Vector@@AEBVmath_IntegerVector@@N@Z (int __cdecl DACTCL_Decompose(class math_Vector &,class math_IntegerVector const &,double)) imported in function "public: void __cdecl BRepApprox_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfApprox::Perform(class math_Vector const &)" (?Perform@BRepApprox_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfApprox@@QEAAXAEBVmath_Vector@@@Z)

These warnings only appear during the link phase of my application. The compilation itself is pretty clean.


Gordon Ferguson's picture

A quick follow-up: I compiled my application using the /E compiler flag in Visual C++. This forces it to simply output the pre-processed code with all the headers spelled out. And, as I expected, the headers I included are such that I see things like, for example

  __declspec( dllexport ) StlAPI_ErrorStatus Write (const TopoDS_Shape& aShape, const Standard_CString aFileName);

There must be a way to tell my application through some compiler flag that OpenCASCADE has been compiled into a static library so that the headers are properly compiled.

Thanks again.

Gordon Ferguson's picture

Another update: since I couldn't figure out how to use the static libraries in my application I bit the bullet and built shared libraries instead. All warnings went away.

It would be nice to know how one can configure an application that uses OpenCASCADE with static libraries using Visual C++. I haven't been able to get rid of the declspec instructions in the headers that are included in my application.