Saturday, July 9, 2011

Static linking of Open CASCADE libraries

For building the windows binaries I have recently switched over to the Open CASCADE Community Edition, located at github: Among other improvements, it provides a CMake makefile that allows for easy switching between shared and static libraries.

Static linking has several advantages over dynamic linking. Static linking removes the dependency on other files from the executable, increasing its file size, but simplifying the distribution and removing the possibility of conflicts between versions of the library. Static linking might also slightly improve the performance and reduce the memory usage because only the functionality that is actually needed is loaded, whereas previously the entire shared library had to be loaded into memory.

Because of this switch, IfcObj and IfcMax now require no additional files, IfcBlender still requires several. As a result of this, the binaries will no longer be distributed inside an installer, but will be provided as a regular zip-file.

Stay posted for the release of IfcOpenShell 0.2.0 this week!


  1. Hi,

    I am very interested in IfcOpenShell.
    I used cmake to generate an vc2010 solution, then during the building, I tried to link IfcObj and IfcParse with Open CASCADE. But I didn't succeed. There is always link error 2001. I used the prebuild pkg from tpaviot. Do you have any suggestion for building the IfcOpenShell standalone library and the executable.

  2. something like:
    Error 5 error LNK2001: unresolved external symbol "public: __thiscall BRepBuilderAPI_Sewing::BRepBuilderAPI_Sewing(double,unsigned int,unsigned int,unsigned int,unsigned int)" (??0BRepBuilderAPI_Sewing@@QAE@NIIII@Z) .....\ifcopenshell-vc10\IfcGeomFaces.obj IfcObj

  3. Hi, thanks for your interest in IfcOpenShell.

    My first guess would be that VC++ does not find all the Open CASCADE libraries, probably because not all dependencies are listed: Under Configuration Properties > Linker > Input, make sure Additional Dependencies include the following and you'll be fine: TKernel.lib TKMath.lib TKBRep.lib TKGeomBase.lib TKGeomAlgo.lib TKG3d.lib TKG2d.lib TKShHealing.lib TKTopAlgo.lib TKMesh.lib TKPrim.lib TKBool.lib TKBO.lib TKFillet.lib

    By the way, you know there is a VC++ 2008 solution file in the /win folder? If you open it up in VC++ 2010 it'll try to convert it for you. The cmake file in the repository is mostly intended for linux environments and in fact has not been tested on windows.

    Kind regards,

  4. Hi Thomas,

    Thanks for your quick reply! I tired the solution in /win. It can be successfully built. But It needs to call the related dll's during executing. I also tried to add all the .lib's you suggested, and it also works fine for building. But it's same when it's being executed, it needs to call dll's like Tkernel.dll...
    ptw. the lib's you listed here is a little different from the ones cmake put into the project file.

    However, I would like to have a standalone version. I guess this maybe cause by that the lib file in "OCE-0.4.0-Win-MSVC2010\oce-0.4.0\Win32\lib" is not suitable. So I rebuilt the OCE lib's from the source "tpaviot-oce-7415baa" and made the cmake option OCE_BUILD_SHARED_LIB unchosen. After I got the new oce lib's, I rebuilt ifcopenshell, this time everything worked fine.


  5. Hi guys,

    Just discovered the IFCOpenShell project via my twitter account. I still didn't check out the source code repository nor tested the program, But I definitely support this project!

    IFC support is one of my main concern. You're welcome to join the oce-dev ml ( to discuss about that. Let me know if you need any help.

    Another information that might help you: Mark Pictor, member of the oce-dev team, just resurrected the old STEPClass Library project (SCL, formerly developped at NIST). Provides a SDAI C++ compliant API, available at:



  6. Thanks for the link, I actually did look at the NIST SCL a while back, I think it has a lot of potential so it's great that there's an ongoing effort to revitalize and build upon the code.

    Kind regards,

  7. I'm trying to compile this on OSX, using OCE 0.4.0 and the svn-updated copy of ifcOpenShell but have compilation problems.

    I converted it into a Qt qmake file and opened in QtCreator IDE (with which I am more familiar), but notice that the problem is identical with CMake generated makefiles.

    In the CMake configuration, I have to point to the correct places for OCC libs and inc (they are in /Library/OCE/0.4.0/lib and .../inc on OSX), whereas your CMake files suggest them to be in /usr/...

    I also noticed that I have to set CMake to not generate developer warnings (it complains about SWIG otherwise). From there on I can generate the Makefile (or XCode project).

    But so far, it didn't compile properly, due to compilation errors, complaining about the use of some private functions.

    "TopTools_ListOfShape(const TopTools_ListOfShape& Other);"
    This method is private and gets called from BRepBuilderAPI_MakeShape.
    So the problems seem to lie inside OCC… But this gets called from ifcGeomFunctions.cpp (line 107) and other places.

    Here is a screenshot of XCode displaying the errors.

    So did you manage to compile ifcOpenShell with OCE? Or with the original OpenCASCADE release?

  8. Hi,

    Thank you for your detailed report. There have indeed been issues with private constructors of Open CASCADE classes, but, with the version of the gcc compiler I am using, they have long disappeared. I can't test anything myself on OSX, but I have just committed some changes that hopefully address the problems you are having.

    In regard to the library- and include directory, this remains an issue, the directories in the cmake file are just a guess, and on many platforms just plain wrong. I hope that someday someone with more knowledge of cmake can make the build file truly cross-platform.

    Could you update your copy and try to build again?

    Kind regards,

  9. Hi Thomas,

    I recently downloaded the source code of IfcOpenShell to compile it using VC++2010. Before doing this, I also downloaded OpenCASCADE 6.5.4 and boost since all these packages are involved in your development. However the compiling always got errors regarding: Cannot open include file: 'gp_Pnt.hxx' or Cannot open include file: 'boost/optional.hpp': No such file or directory, etc. I actually had set the include directories in VC++ Directories. Can I get your suggestions how to deal with this kind of problem?

    Thanks a lot in advance!


  10. Hello Wei,

    You could use CMake to generate your MSVC project files. The windows distribution of CMake comes with a gui tool that detects your compiler and allows you to set the paths of the dependencies. I personally do not use CMake on Windows a lot, but I do sometimes use the MSVC property sheets to configure projects. In general I think it is quite common that these MSVC projects have to be setup manually, but if you have any suggestions on how to ease configuration and compilation of IfcOpenShell, let us know!

    Kind regards,