Build OCCT

Before building OCCT, make sure to have all required third-party libraries installed. The list of required libraries depends on what OCCT modules will be used, and your preferences. The typical minimum is FreeType (necessary for Visualization) and Tcl/Tk (for DRAW). See requirements on 3rdparty libraries for a full list.

在构建OCCT之前,请确保安装了所有必需的第三方库。

所需库的列表取决于将使用的OCCT模块以及您的偏好。

典型的最低要求是FreeType(对于可视化而言是必需的)和Tcl/Tk(用于DRAW)。

请参阅三方库的要求以获取完整列表。

The easiest way to install third-party libraries is to download archive with pre-built binaries, corresponding to your target configuration, from Development Portal. You can also build third-party libraries from their sources, see Build 3rd-parties for instructions.

安装第三方库的最简单方法是,从开发门户下载对应目标配置的预构建二进制文件的存档。

您还可以从源代码构建第三方库,有关说明,请参阅构建第三方

On Linux and macOS we recommend to use libraries maintained by distributive developers, when possible.

在Linux和macOS上,如果可能的话,我们建议使用由发行版开发者维护的库。

Building with CMake tool 通过CMake工具进行构建

This chapter describes the CMake-based build process, which is now suggested as a standard way to produce the binaries of Open CASCADE Technology from sources. OCCT requires CMake version 3.1 or later.

本章描述了基于 CMake的构建过程,现在建议使用CMake作为从源代码生成Open CASCADE Technology二进制文件的标准化方式。

OCCT需要CMake版本3.1或更高版本。

CMake is a tool that generates the actual project files for the selected target build system (e.g. Unix makefiles) or IDE (e.g. Visual Studio 2010). Here we describe the build procedure on the example of Windows platform with Visual Studio 2010. However, CMake is cross-platform and can be used to build OCCT on Linux and macOS in essentially the same way.

CMake是一个生成所选目标构建系统(例如Unix Makefile)或IDE(例如Visual Studio 2010)的实际项目文件的工具。

这里我们以Windows平台上的Visual Studio 2010为例来描述构建过程。

然而,CMake是跨平台的,可以用同样的方式来构建Linux和macOS上的OCCT。

CMake deals with three directories: source, build or binary and installation.

  • The source directory is where the sources of OCCT are located in your file system;

  • The build or binary directory is where all files created during CMake configuration and generation process will be located. The mentioned process will be described below.

  • The installation directory is where binaries will be installed after building the INSTALL project that is created by CMake generation process, along with header files and resources required for OCCT use in applications.

CMake处理三个目录:源码、构建或二进制文件以及安装目录。

  • 源码目录是您文件系统中OCCT源码的存放位置;

  • 构建或二进制文件目录是CMake配置和生成过程中创建的所有文件的存放位置。上述过程将在下文中描述。

  • 安装目录是在构建INSTALL项目(由CMake生成过程创建,同时包含OCCT应用程序所需头文件和资源)后,二进制文件将被安装的位置。

The good practice is not to use the source directory as a build one. Different configurations should be built in different build directories to avoid conflicts. It is however possible to choose one installation directory for several configurations of OCCT (differentiated by platform, bitness, compiler and build type), for example:

好的做法是不使用源码目录作为构建目录。

在不同的构建目录中构建不同的配置,以避免冲突。

不过,可以选择一个安装目录用于几个OCCT的配置(由平台、位宽、编译器和构建类型区分),例如:

d:/occt/                   - the source directory
d:/tmp/occt-build-vc10-x64 - the build directory with the generated
                             solution and other intermediate files created during a CMake tool working
d:/occt-install            - the installation directory that is
                             able to contain several OCCT configurations
d:/occt/ - 源码目录
d:/tmp/occt-build-vc10-x64 - 构建目录,包含生成的解决方案和其他中间文件,这些文件是在CMake工具工作时创建的
d:/occt-install - 安装目录,可以包含多个OCCT配置文件

Configuration process 配置过程

For unexperienced users we recommend to start with cmake-gui – a cross-platform GUI tool provided by CMake on Windows, Mac and Linux. A command-line alternative, ccmake can also be used.

对于没有经验的用户,我们建议从cmake-gui开始——这是跨平台的GUI工具,由CMake在Windows、Mac和Linux上提供。还可以使用命令行替代工具ccmake

If the command-line tool is used, run the tool from the build directory with a single argument indicating the source (relative or absolute path) directory, and press c to configure:

如果使用命令行工具,从构建目录中运行该工具,并传入一个参数,指示源(相对或绝对路径)目录,然后按c进行配置:

cd d:/tmp/occt-build-vc10-x64
ccmake d:/occt

If the GUI tool is used, run this tool without additional arguments and after that specify the source directory by clicking Browse Source and the build (binary) one by clicking Browse Build:

如果使用GUI工具,无需添加任何参数即可运行该工具,然后点击Browse Source(浏览源)指定源目录,点击Browse Build(浏览构建)指定构建(二进制)目录:

  • Note

    Each configuration of the project should be built in its own directory. When building multiple configurations it is suggested to indicate in the name of build directories the system, bitness and compiler (e.g., d:/occt/build/win32-vc10).

  • 注意

    项目的每个配置都应在自己的目录中进行构建。在构建多个配置时,建议在构建目录的名称中指明系统、位宽和编译器(例如,d:/occt/build/win32-vc10)。

Once the source and build directories are selected, "Configure" button should be pressed in order to start manual configuration process. It begins with selection of a target configurator. It is "Visual Studio 10 2010 Win64" in our example.

一旦选择了源码和构建目录,就应该按下“Configure”按钮以开始手动配置过程。

这从选择目标配置器开始。在我们的例子中,它是“Visual Studio 10 2010 Win64”。

  • Note

    To build OCCT for Universal Windows Platform (UWP) specify the path to toolchain file for cross-compiling d:/occt/adm/templates/uwp.toolchain.config.cmake. Alternatively, if you are using CMake from the command line add options -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0. Universal Windows Platform (UWP) is supported only on "Visual Studio 14 2015". File CASROOT/samples/xaml/ReadMe.md describes the building procedure of XAML (UWP) sample.

  • 要为**通用Windows平台(UWP)**构建OCCT,请指定用于交叉编译的工具链文件的路径,即d:/occt/adm/templates/uwp.toolchain.config.cmake。或者,如果您使用的是命令行中的CMake,请添加选项-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0。仅在“Visual Studio 14 2015”上支持通用Windows平台(UWP)。文件CASROOT/samples/xaml/ReadMe.md描述了XAML(UWP)样本的构建过程。

Once "Finish" button is pressed, the first pass of the configuration process is executed. At the end of the process, CMake outputs the list of environment variables, which have to be properly specified for successful configuration.

一旦按下“Finish”按钮,就会执行配置过程的第一遍。

在过程结束时,CMake会输出必须正确指定的环境变量列表,以便成功配置。

The error message provides some information about these variables. This message will appear after each pass of the process until all required variables are specified correctly.

错误消息会提供有关这些变量的信息。此消息将在过程的每次遍历后显示,直到所有必需的变量都正确指定。

The change of the state of some variables can lead to the appearance of new variables. The new variables appeared after the pass of the configuration process are highlighted with red color by CMake GUI tool.

某些变量的状态更改可能导致新变量的出现。配置过程遍历后出现的新变量将由CMake GUI工具以红色突出显示。

  • Note

    There is "grouped" option, which groups variables with a common prefix.

  • 注意

    有一个“grouped”选项,可以将具有共同前缀的变量组合在一起。

The following table gives the full list of environment variables used at the configuration stage:

下表列出了配置阶段使用的完整环境变量列表:

VariableTypePurpose

CMAKE_BUILD_TYPE

String

Specifies the build type on single-configuration generators (such as make). Possible values are Debug, Release and RelWithDebInfo

USE_FREETYPE

Boolean

Indicates whether FreeType product should be used in OCCT for text rendering

USE_FREEIMAGE

Boolean

Indicates whether FreeImage product should be used in OCCT visualization module for support of popular graphics image formats (PNG, BMP, etc.)

USE_OPENVR

Boolean

Indicates whether OpenVR product should be used in OCCT visualization module for support of Virtual Reality

USE_OPENGL

Boolean

Indicates whether TKOpenGl graphic driver using OpenGL library (desktop) should be built within OCCT visualization module

USE_GLES2

Boolean

Indicates whether TKOpenGles graphic driver using OpenGL ES library (embedded OpenGL) should be built within OCCT visualization module

USE_RAPIDJSON

Boolean

Indicates whether RapidJSON product should be used in OCCT Data Exchange module for support of glTF mesh file format

USE_DRACO

Boolean

Indicates whether Draco product should be used in OCCT Data Exchange module for support of Draco compression in glTF mesh file format

USE_TK

Boolean

Indicates whether Tcl/Tk product should be used in OCCT Draw Harness module for user interface (in addition to Tcl, which is mandatory for Draw Harness)

USE_TBB

Boolean

Indicates whether TBB (Threading Building Blocks) 3rd party is used or not. Note that OCCT remains parallel even without TBB product

USE_VTK

Boolean

Indicates whether VTK 3rd party is used or not. OCCT comes with a bridge between CAD data representation and VTK by means of its dedicated VIS component (VTK Integration Services). You may skip this 3rd party unless you are planning to use VTK visualization for OCCT geometry. See the official documentation VTK Integration Services (VIS) for the details on VIS

3RDPARTY_DIR

Path

Defines the root directory where all required 3rd party products will be searched. Once you define this path it is very convenient to click "Configure" button in order to let CMake automatically detect all necessary products

3RDPARTY_FREETYPE_*

Path

Path to FreeType binaries

3RDPARTY_TCL_* 3RDPARTY_TK_*

Path

Path to Tcl/Tk binaries

3RDPARTY_FREEIMAGE*

Path

Path to FreeImage binaries

3RDPARTY_TBB*

Path

Path to TBB binaries

3RDPARTY_VTK_*

Path

Path to VTK binaries

BUILD_MODULE_

Boolean

Indicates whether the corresponding OCCT module should be built or not. It should be noted that some toolkits of a module can be built even if this module is not checked (this happens if some other modules depend on these toolkits). The main modules and their descriptions can be found in User Guides

BUILD_LIBRARY_TYPE

String

Specifies the type of library to be created. "Shared" libraries are linked dynamically and loaded at runtime. "Static" libraries are archives of object files used when linking other targets. Note that Draw Harness plugin system is incompatible with "Static" builds, and therefore it is disabled for these builds.

BUILD_ADDITIONAL_TOOLKITS

String

Semicolon-separated individual toolkits to include into build process. If you want to build some particular libraries (toolkits) only, then you may uncheck all modules in the corresponding BUILD_MODUE_ options and provide the list of necessary libraries here. Of course, all dependencies will be resolved automatically

BUILD_YACCLEX

Boolean

Enables Flex/Bison lexical analyzers. OCCT source files relating to STEP reader and ExprIntrp functionality are generated automatically with Flex/Bison. Checking this option leads to automatic search of Flex/Bison binaries and regeneration of the mentioned files

BUILD_SAMPLES_MFC

Boolean

Indicates whether MFC samples should be built together with OCCT. This option is only relevant to Windows platforms

BUILD_SAMPLES_QT

Boolean

Indicates whether QT samples should be built together with OCCT.

BUILD_Inspector

Boolean

Indicates whether Inspector should be built together with OCCT.

BUILD_DOC_Overview

Boolean

Indicates whether OCCT overview documentation project should be created together with OCCT. It is not built together with OCCT. Checking this option leads to automatic search of Doxygen binaries. Its building calls Doxygen command to generate the documentation in HTML format

BUILD_PATCH

Path

Points to the directory recognized as a "patch" for OCCT. If specified, the files from this directory take precedence over the corresponding native OCCT sources. This way you are able to introduce patches to Open CASCADE Technology not affecting the original source distribution

BUILD_WITH_DEBUG

Boolean

Enables extended messages of many OCCT algorithms, usually printed to cout. These include messages on internal errors and special cases encountered, timing, etc.

BUILD_ENABLE_FPE_SIGNAL_HANDLER

Boolean

Enable/Disable the floating point exceptions (FPE) during DRAW execution only. Corresponding environment variable (CSF_FPE) can be changed manually in custom.bat/sh scripts without regeneration by CMake.

BUILD_CPP_STANDARD

String

Employ corresponding c++ standard (C++11, C++14, ..C++23) for building OCCT

CMAKE_CONFIGURATION_TYPES

String

Semicolon-separated CMake configurations

INSTALL_DIR

Path

Points to the installation directory. INSTALL_DIR is a synonym of CMAKE_INSTALL_PREFIX. The user can specify both INSTALL_DIR or CMAKE_INSTALL_PREFIX

INSTALL_DIR_BIN

Path

Relative path to the binaries installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_BIN})

INSTALL_DIR_SCRIPT

Path

Relative path to the scripts installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_SCRIPT})

INSTALL_DIR_LIB

Path

Relative path to the libraries installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_LIB})

INSTALL_DIR_INCLUDE

Path

Relative path to the includes installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_INCLUDE})

INSTALL_DIR_RESOURCE

Path

Relative path to the resources installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_RESOURCE})

INSTALL_DIR_LAYOUT

String

Defines the structure of OCCT files (binaries, resources, headers, etc.) for the install directory. Two variants are predefined: for Windows (standard OCCT layout) and for Unix operating systems (standard Linux layout). If needed, the layout can be customized with INSTALL_DIR_* variables

INSTALL_DIR_DATA

Path

Relative path to the data files installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_DATA})

INSTALL_DIR_SAMPLES

Path

Relative path to the samples installation directory. Note that only "samples/tcl" folder will be installed. (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_SAMPLES})

INSTALL_DIR_TESTS

Path

Relative path to the tests installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_TESTS})

INSTALL_DIR_DOC

Path

Relative path to the documentation installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_DOC})

INSTALL_FREETYPE

Boolean

Indicates whether FreeType binaries should be installed into the installation directory

INSTALL_FREEIMAGE

Boolean

Indicates whether FreeImage binaries should be installed into the installation directory

INSTALL_TBB

Boolean

Indicates whether TBB binaries should be installed into the installation directory

INSTALL_VTK

Boolean

Indicates whether VTK binaries should be installed into the installation directory

INSTALL_TCL

Boolean

Indicates whether TCL binaries should be installed into the installation directory

INSTALL_TEST_CASES

Boolean

Indicates whether non-regression OCCT test scripts should be installed into the installation directory

INSTALL_DOC_Overview

Boolean

Indicates whether OCCT overview documentation should be installed into the installation directory

变量名类型目的

CMAKE_BUILD_TYPE

字符串

在单配置生成器(例如make)上指定构建类型。可能的值包括Debug、Release和RelWithDebInfo

USE_FREETYPE

布尔值

指示OCCT是否应使用FreeType产品进行文本渲染

USE_FREEIMAGE

布尔值

指示OCCT可视化模块是否应使用FreeImage产品支持流行的图形图像格式(PNG、BMP等)

USE_OPENVR

布尔值

指示OCCT可视化模块是否应使用OpenVR产品支持虚拟现实

USE_OPENGL

布尔值

指示OCCT可视化模块是否应构建使用OpenGL库(桌面)的TKOpenGl图形驱动程序

USE_GLES2

布尔值

指示OCCT可视化模块是否应构建使用OpenGL ES库(嵌入式OpenGL)的TKOpenGles图形驱动程序

USE_RAPIDJSON

布尔值

指示OCCT数据交换模块是否应使用RapidJSON产品支持glTF网格文件格式

USE_DRACO

布尔值

指示OCCT数据交换模块是否应使用Draco产品支持glTF网格文件格式中的Draco压缩

USE_TK

布尔值

指示OCCT绘图管理模块是否应使用Tcl/Tk产品用于用户界面(除了Draw Harness强制要求使用的Tcl)

USE_TBB

布尔值

指示是否使用TBB(Threading Building Blocks)第三方。请注意,即使没有TBB产品,OCCT仍然保持并行

USE_VTK

布尔值

指示是否使用VTK第三方。OCCT通过其专门的VIS组件(VTK集成服务)提供了CAD数据表示和VTK之间的桥梁。除非您计划使用VTK可视化OCCT几何,否则可以跳过此第三方。有关VIS的详细信息,请参阅官方文档VTK集成服务(VIS)

3RDPARTY_DIR

路径

定义所有必需的第三方产品的根目录的路径。一旦定义此路径,点击“配置”按钮让CMake自动检测所有必要的产品非常方便

3RDPARTY_FREETYPE_*

路径

FreeType二进制文件的路径

3RDPARTY_TCL_* 3RDPARTY_TK_*

路径

Tcl/Tk二进制文件的路径

3RDPARTY_FREEIMAGE*

路径

FreeImage二进制文件的路径

3RDPARTY_TBB*

路径

TBB二进制文件的路径

3RDPARTY_VTK_*

路径

VTK二进制文件的路径

BUILD_MODULE_

布尔值

指示是否构建相应的OCCT模块。需要注意的是,即使未选中此模块,某些其他模块依赖的工具包也可以构建。主要模块及其描述可在用户指南中找到

BUILD_LIBRARY_TYPE

字符串

指定要创建的库的类型。"共享"库在运行时动态链接并加载。"静态"库是用于链接其他目标的对象文件的归档。请注意,Draw Harness插件系统与"静态"构建不兼容,因此在这些构建中禁用了它。

BUILD_ADDITIONAL_TOOLKITS

字符串

以分号分隔的要在构建过程中包括的各个工具包。如果您只想构建一些特定的库(工具包),那么您可以在相应的*BUILD_MODUE_*选项中取消选中所有模块,并在此处提供必要的库列表。当然,所有依赖项将自动解析。

BUILD_YACCLEX

布尔值

启用Flex / Bison词法分析器。使用Flex / Bison自动生成与STEP阅读器和ExprIntrp功能相关的OCCT源文件。选中此选项将自动搜索Flex / Bison二进制文件并重新生成提到的文件。

BUILD_SAMPLES_MFC

布尔值

表示是否应将MFC样本与OCCT一起构建。此选项仅适用于Windows平台。

BUILD_SAMPLES_QT

布尔值

表示是否应将QT样本与OCCT一起构建。

BUILD_Inspector

布尔值

表示是否应将Inspector与OCCT一起构建。

BUILD_DOC_Overview

布尔值

表示是否应与OCCT一起创建OCCT概述文档项目。它不与OCCT一起构建。选中此选项将自动搜索Doxygen二进制文件。它的构建调用Doxygen命令以生成HTML格式的文档。

BUILD_PATCH

路径

指向被识别为OCCT "补丁"的目录的路径。如果指定了该目录,则来自该目录的文件优先于相应的本地OCCT源文件。这样,您就可以向Open CASCADE Technology引入补丁,而不影响原始源代码分发。

BUILD_WITH_DEBUG

布尔值

启用OCCT算法的扩展消息,通常打印到cout。包括内部错误和遇到的特殊情况、计时等信息。

BUILD_ENABLE_FPE_SIGNAL_HANDLER

布尔值

在仅DRAW执行期间启用/禁用浮点异常(FPE)。相应的环境变量(CSF_FPE)可以在不重新生成的情况下手动在custom.bat / sh脚本中更改。

BUILD_CPP_STANDARD

字符串

为构建OCCT采用相应的C++标准(C++11、C++14、...C++23)

CMAKE_CONFIGURATION_TYPES

字符串

以分号分隔的CMake配置类型

INSTALL_DIR

路径

指向安装目录的路径。INSTALL_DIRCMAKE_INSTALL_PREFIX 的同义词。用户可以同时指定INSTALL_DIRCMAKE_INSTALL_PREFIX

INSTALL_DIR_BIN

路径

二进制文件安装目录的相对路径(绝对路径为 ${INSTALL_DIR}/${INSTALL_DIR_BIN})

INSTALL_DIR_SCRIPT

路径

脚本安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_SCRIPT})

INSTALL_DIR_LIB

路径

库文件安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_LIB})

INSTALL_DIR_INCLUDE

路径

头文件安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_INCLUDE})

INSTALL_DIR_RESOURCE

路径

资源文件安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_RESOURCE})

INSTALL_DIR_LAYOUT

字符串

为安装目录定义OCCT文件(二进制文件、资源文件、头文件等)的结构。预定义了两种变体:适用于Windows(标准OCCT布局)和适用于Unix操作系统(标准Linux布局)。如果需要,可以使用INSTALL_DIR_*变量自定义布局

INSTALL_DIR_DATA

路径

数据文件安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_DATA})

INSTALL_DIR_SAMPLES

路径

样本安装目录的相对路径。请注意,只有“samples/tcl”文件夹会被安装。(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_SAMPLES})

INSTALL_DIR_TESTS

路径

测试安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_TESTS})

INSTALL_DIR_DOC

路径

文档安装目录的相对路径(绝对路径为${INSTALL_DIR}/${INSTALL_DIR_DOC})

INSTALL_FREETYPE

布尔值

表示是否应将FreeType二进制文件安装到安装目录中

INSTALL_FREEIMAGE

布尔值

表示是否应将FreeImage二进制文件安装到安装目录中

INSTALL_TBB

布尔值

表示是否应将TBB二进制文件安装到安装目录中

INSTALL_VTK

布尔值

表示是否应将VTK二进制文件安装到安装目录中

INSTALL_TCL

布尔值

表示是否应将TCL二进制文件安装到安装目录中

INSTALL_TEST_CASES

布尔值

表示是否应将非回归OCCT测试脚本安装到安装目录中

INSTALL_DOC_Overview

布尔值

表示是否应将OCCT概述文档安装到安装目录中

  • Note

    Only the forward slashes ("/") are acceptable in the CMake options defining paths.

  • 注意

    在CMake选项中定义路径时,只接受斜杠(“/”)。

3rd party search mechanism 第三方搜索机制

If 3RDPARTY_DIR directory is defined, then required 3rd party binaries are sought in it, and default system folders are ignored. The procedure expects to find binary and header files of each 3rd party product in its own sub-directory: bin, lib and include. The results of the search (achieved on the next pass of the configuration process) are recorded in the corresponding variables:

如果定义了3RDPARTY_DIR目录,则在其中查找所需的第三方二进制文件,并忽略默认系统文件夹。该过程期望在每个第三方产品的子目录中找到二进制文件和头文件:binlibinclude。搜索结果(在配置过程的下一轮中获取)记录在相应的变量中:

  • 3RDPARTY_<PRODUCT>_DIR – path to the 3rdparty directory (with directory name) (e.g. D:/3rdparty/tcltk-86-32);

  • 3RDPARTY_<PRODUCT>_LIBRARY_DIR – path to the directory containing a library (e.g. D:/3rdparty/tcltk-86-32/lib);

  • 3RDPARTY_<PRODUCT>_INCLUDE_DIR – path to the directory containing a header file (e.g., D:/3rdparty/tcltk-86-32/include);

  • 3RDPARTY_<PRODUCT>_DLL_DIR – path to the directory containing a shared library (e.g., D:/3rdparty/tcltk-86-32/bin) This variable is only relevant to Windows platforms.

  • 3RDPARTY_<PRODUCT>_DIR– 第三方目录的路径(带有目录名称)(例如D:/3rdparty/tcltk-86-32);

  • 3RDPARTY_<PRODUCT>_LIBRARY_DIR – 包含库目录的路径(例如D:/3rdparty/tcltk-86-32/lib);

  • 3RDPARTY_<PRODUCT>_INCLUDE_DIR– 包含头文件目录的路径(例如D:/3rdparty/tcltk-86-32/include);

  • 3RDPARTY_<PRODUCT>_DLL_DIR– 包含共享库目录的路径(例如,D:/3rdparty/tcltk-86-32/bin),该变量仅与 Windows 平台相关。

Note

Each library and include directory should be children of the product directory if the last one is defined.

注意:

如果定义了库和include目录,则每个库和include目录都应该是产品目录的子目录。

The search process is as follows:

  1. Common path: 3RDPARTY_DIR

  2. Path to a particular 3rd-party library: 3RDPARTY_<PRODUCT>_DIR

  3. Paths to headers and binaries:

    1. 3RDPARTY_<PRODUCT>_INCLUDE_DIR

    2. 3RDPARTY_<PRODUCT>_LIBRARY_DIR

    3. 3RDPARTY_<PRODUCT>_DLL_DIR

搜索过程如下:

  1. 常用路径: 3RDPARTY_DIR

  2. 特定第三方库的路径: 3RDPARTY_<PRODUCT>_DIR

  3. 头文件和二进制文件的路径:

    1. 3RDPARTY_<PRODUCT>_INCLUDE_DIR

    2. 3RDPARTY_<PRODUCT>_LIBRARY_DIR

    3. 3RDPARTY_<PRODUCT>_DLL_DIR

If a variable of any level is not defined (empty or <variable name>-NOTFOUND) and the upper level variable is defined, the content of the non-defined variable will be sought at the next configuration step. If the search process at level 3 does not find the required files, it seeks in default places.

If a search result (include path, or library path, or dll path) does not meet your expectations, you can change 3RDPARTY_<PRODUCT>_*_DIR variable, clear (if they are not empty) 3RDPARTY_<PRODUCT>_DLL_DIR, 3RDPARTY_<PRODUCT>_INCLUDE_DIR and 3RDPARTY_<PRODUCT>_LIBRARY_DIR variables (or clear one of them) and run the configuration process again.

如果任一级别的变量未定义(空或<variable name>-NOTFOUND)且定义了上一级变量,则将在下一个配置步骤中查找未定义变量的内容。如果在第3级的搜索过程中没有找到所需的文件,则将在默认位置进行搜索。

如果搜索结果(包含路径、或库路径、或 dll 路径)不符合您的期望,您可以更改变量3RDPARTY_<PRODUCT>_*_DIR ,清除(如果它们不为空)3RDPARTY_<PRODUCT>_DLL_DIR3RDPARTY_<PRODUCT>_INCLUDE_DIR3RDPARTY_<PRODUCT>_LIBRARY_DIR 等变量(或清除其中之一),并再执行一次配置过程。

At this time the search will be performed in the newly identified directory and the result will be recorded to corresponding variables (replace old value if it is necessary). For example, 3RDPARTY_FREETYPE_DIR variable

d:/3rdparty/freetype-2.4.10

can be changed to

d:/3rdparty/freetype-2.5.3

此时将在新识别的目录中进行搜索,并将结果记录到相应的变量中(必要时替换旧值)。例如,变量 3RDPARTY_FREETYPE_DIR

d:/3rdparty/freetype-2.4.10

被替换为:

d:/3rdparty/freetype-2.5.3

During the configuration process the related variables (3RDPARTY_FREETYPE_DLL_DIR, 3RDPARTY_FREETYPE_INCLUDE_DIR and 3RDPARTY_FREETYPE_LIBRARY_DIR) will be filled with new found values.

  • Note

    The names of searched libraries and header files are hard-coded. If there is the need to change their names, change appropriate CMake variables (edit CMakeCache.txt file or edit in cmake-gui in advance mode) without reconfiguration: 3RDPARTY_<PRODUCT>_INCLUDE for include, 3RDPARTY_<PRODUCT>_LIB for library and 3RDPARTY_<PRODUCT>_DLL for shared library.

在配置过程中,相关变量(3RDPARTY_FREETYPE_DLL_DIR, 3RDPARTY_FREETYPE_INCLUDE_DIR3RDPARTY_FREETYPE_LIBRARY_DIR)将被赋值为新找到的值。

注意: 搜索到的库文件和头文件的名称是硬编码的。如果需要更改它们的名称,请更改对应的 CMake 变量(编辑 CMakeCache.txt 文件或在高级模式下在 cmake-gui 中编辑),无需重新配置:include 3RDPARTY_<PRODUCT>_INCLUDE、库3RDPARTY_<PRODUCT>_LIB、共享库3RDPARTY_<PRODUCT>_DLL

Projects generation

Once the configuration process is done, the "Generate" button is used to prepare project files for the target IDE. In our exercise the Visual Studio solution will be automatically created in the build directory.

配置完成后,“生成”按钮用于为目标 IDE 准备项目文件。在我们的练习中,Visual Studio 解决方案将在构建目录中自动创建。

Building 构建

Go to the build folder, start the Visual Studio solution OCCT.sln and build it by clicking Build -> Build Solution.

打开构建文件夹,启动 Visual Studio 解决方案OCCT.sln,并通过单击Build -> Build Solution来构建它。

By default, the build solution process skips the building of the INSTALL and Overview projects. When the building process is finished build:

  • Overview project to generate OCCT overview documentation (if BUILD_DOC_Overview variable is checked)

  • the INSTALL project to run the installation process

For this, right-click on the Overview/INSTALL project and select Project Only -> Build Only -> Overview/INSTALL in the solution explorer.

默认情况下,构建解决方案过程会跳过 INSTALL 和 Overview 项目的构建。构建过程完成后:

  • Overview项目用于生成 OCCT 概述文档(如果选中了变量BUILD_DOC_Overview

  • INSTALL项目用来运行安装过程

如果要做这些,右键单击 Overview/INSTALL 项目,然后在解决方案资源管理器中选择“Project Only”->“Build Only” -> “Overview/INSTALL” 。

Installation 安装

Installation is a process of extracting redistributable resources (binaries, include files etc) from the build directory into the installation one. The installation directory will be free of project files, intermediate object files and any other information related to the build routines.

Normally you use the installation directory of OCCT to link against your specific application. The directory structure is as follows:

安装是将可再发布资源(二进制文件、include文件等)从构建目录提取到安装目录的过程。安装目录将不含项目文件、中间目标文件以及与构建例程相关的任何其他信息。

通常,您使用 OCCT 的安装目录来链接到您指定的应用程序。目录结构如下:

data            - data files for OCCT (brep, iges, stp)
doc             - OCCT overview documentation in HTML format
inc             - header files
samples         - samples
src             - all required source files for OCCT
tests           - OCCT test suite
win32\vc10\bind - binary files (installed 3rdparties and occt)
          \libd - libraries (installed 3rdparties and occt)
  • Note

    The above example is given for debug configuration. However, it is generally safe to use the same installation directory for the release build. In the latter case the contents of install directory will be enriched with subdirectories and files related to the release configuration. In particular, the binaries directory win64 will be expanded as follows:\win32\vc10\bind \libd \bin \lib

    If CMake installation flags are enabled for the 3rd party products (e.g. INSTALL_FREETYPE), then the corresponding binaries will be copied to the same bin(d) and lib(d) directories together with the native binaries of OCCT. Such organization of libraries can be especially helpful if your OCCT-based software does not use itself the 3rd parties of Open CASCADE Technology (thus, there is no sense to pack them into dedicated directories).

注意:

上面的示例是针对调试配置的。但是,对于发布版本使用相同的安装目录通常是安全的。在后一种情况下,安装目录的内容将通过与发布配置相关的子目录和文件来丰富。特别是,二进制目录 win64 将扩展如下:

\win32\vc10\bind
     \libd
     \bin
     \lib

如果为第 3 方产品启用了 CMake 安装标志(例如 INSTALL_FREETYPE),则相应的二进制文件将与 OCCT 本地的二进制文件一起复制到相同的 bin(d) 和 lib(d) 目录。如果您基于 OCCT 的软件本身不使用 Open CASCADE Technology 的第 3 方,这种库的组织可能特别有用(因此,将它们打包到专用目录中是没有意义的)。

The installation folder contains the scripts to run DRAWEXE (draw.bat or draw.sh), samples (if they were installed) and overview.html (short-cut for installed OCCT overview documentation).

安装文件夹包含运行DRAWEXE 的脚本(draw.bat 或 draw.sh)、示例(如果已安装)和overview.html(已安装的OCCT 概述文档的快捷方式)。

Cross-compiling (Android) 交叉编译(Android)

This section describes the steps to build OCCT libraries for Android from a complete source package with GNU make (makefiles). The steps on Windows 7 and Ubuntu 15.10 are similar. There is the only one difference: makefiles are built with mingw32-make on Windows and native GNU make on Ubuntu.

本节介绍使用 GNU make(makefile)从完整源代码包构建适用于 Android 的 OCCT 库的步骤。Windows 7 和 Ubuntu 15.10 上的步骤类似。唯一的区别是:makefile 在 Windows 上使用 mingw32-make 构建,在 Ubuntu 上使用本机 GNU make 构建。

Required tools (download and install if it is required):

Run GUI tool provided by CMake and:

  • Specify the root folder of OCCT ($CASROOT, which contains CMakelists.txt file) by clicking Browse Source.

  • Specify the location (build folder) for CMake generated project files by clicking Browse Build.

所需工具(如果需要,请下载并安装):

运行 CMake 提供的 GUI 工具并:

  • 通过单击Browse Source指定 OCCT 的根文件夹($CASROOT,其中包含CMakelists.txt文件) 。

  • 通过单击Browse Build指定 CMake 生成的项目文件的位置(构建文件夹)。

Click Configure button. It opens the window with a drop-down list of generators supported by CMake project. Select "MinGW MakeFiles" item from the list

单击配置按钮。它会打开一个窗口,其中包含 CMake 项目支持的生成器下拉列表。从列表中选择“MinGW MakeFiles”项

  • Choose "Specify toolchain file for cross-compiling", and click "Next".

  • 选择“指定交叉编译的工具链文件”,然后单击“下一步”。

  • Specify a toolchain file at the next dialog to android.toolchain.cmake, and click "Finish".

  • 在下一个对话框中指定工具链文件android.toolchain.cmake,然后单击“完成”。

If ANDROID_NDK environment variable is not defined in current OS, add cache entry ANDROID_NDK (entry type is PATH) – path to the NDK folder ("Add Entry" button):

如果ANDROID_NDK当前操作系统中未定义环境变量,请添加缓存条目ANDROID_NDK(条目类型为PATH) - NDK 文件夹的路径(“添加条目”按钮):

If on Windows the message is appeared: "CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles" CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.", specify CMAKE_MAKE_PROGRAM to mingw32-make executable.

如果在 Windows 上出现消息:“CMake 错误:CMake 无法找到与“MinGW Makefiles”CMAKE_MAKE_PROGRAM 对应的构建程序未设置。您可能需要选择不同的构建工具。”,指定为 mingw32-make 可执行文件CMAKE_MAKE_PROGRAM

How to configure OCCT, see Configure section taking into account the specific configuration variables for Android:

  • ANDROID_ABI = armeabi-v7a

  • ANDROID_NATIVE_API_LEVEL = 15

  • ANDROID_NDK_LAYOUT is equal to CMAKE_BUILD_TYPE variable

  • BUILD_MODULE_Draw = OFF

如何配置 OCCT,请参阅配置部分并考虑 Android 的特定配置变量:

  • ANDROID_ABI=armeabi-v7a

  • ANDROID_NATIVE_API_LEVEL=15

  • ANDROID_NDK_LAYOUT等于CMAKE_BUILD_TYPE变量

  • BUILD_MODULE_Draw=OFF

Click Generate button and wait until the generation process is finished. Then makefiles will appear in the build folder (e.g. D:/tmp/occt-android ).

Open console and go to the build folder. Type "mingw32-make" (Windows) or "make" (Ubuntu) to start build process:

单击生成按钮并等待生成过程完成。然后 makefiles 将出现在构建文件夹中(例如D:/tmp/occt-android)。

打开控制台并转到构建文件夹。输入“mingw32-make”(Windows) 或“make”(Ubuntu) 开始构建过程:

mingw32-make

or或者

make

Parallel building can be started with using -jN argument of "mingw32-make/make", where N is the number of building threads:

并行构建可以使用“mingw32-make/make” -jN 参数启动,其中N是构建线程的数量:

mingw32-make -j4

or或者

make -j4

Type "mingw32-make/make" with argument "install" to place the libraries to the install folder:

输入“mingw32-make/make” 带有参数“install”的,将库放置到安装文件夹中:

mingw32-make install

or或者

make install

Building with Genproj tool

genproj is a legacy tool (originated from command "wgenproj" in WOK) for generation of Visual Studio, Code::Blocks, Qt Creator (qmake), and XCode project files for building Open CASCADE Technology. These project files are placed inside OCCT directory (in adm subfolder) and use relative paths, thus can be moved together with sources. The project files included in official distribution of OCCT are generated by this tool.

  • Note

    If you have official distribution with project files included, you can use them directly without a need to call genproj.

genproj is a less flexible alternative to use of CMake build system (see Building with CMake tool), but still has some small features useful for OCCT development.

Configuration process

The environment is defined in the file custom.sh (on Linux and macOS) or custom.bat (on Windows) which can be edited directly:

  • ARCH – architecture (32 or 64), affects only PATH variable for execution

  • HAVE_* – flags to enable or disable use of optional third-party products

  • CSF_OPT_* – paths to search for includes and binaries of all used third-party products

  • SHORTCUT_HEADERS – defines method for population of folder inc by header files. Supported methods are:

  • Copy - headers will be copied from src;

  • ShortCut - short-cut header files will be created, redirecting to same-named header located in src;

    • HardLink - hard links to headers located in src will be created.

  • VCVER – specification of format of project files, defining also version of Visual Studio to be used, and default name of the sub-folder for binaries:

  • Add paths to includes of used third-party libraries in variable CSF_OPT_INC.

  • Add paths to their binary libraries in variable CSF_OPT_LIB64.

  • For optional third-party libraries, set corresponding environment variable HAVE_<LIBRARY_NAME> to either false, e.g. export HAVE_FREEIMAGE=false.

VCVERVisual Studio versionWindows PlatformBinaries folder name

vc10

2010 (10)

Desktop (Windows API)

vc10

vc11

2012 (11)

Desktop (Windows API)

vc11

vc12

2013 (12)

Desktop (Windows API)

vc12

vc14

2015 (14)

Desktop (Windows API)

vc14

vc14-uwp

2015 (14)

UWP (Universal Windows Platform)

vc14-uwp

vc141

2017 (15)

Desktop (Windows API)

vc14

vc141-uwp

2017 (15)

UWP (Universal Windows Platform)

vc14-uwp

vc142

2019 (16)

Desktop (Windows API)

vc14

vc142-uwp

2019 (16)

UWP (Universal Windows Platform)

vc14-uwp

vc143

2022 (17)

Desktop (Windows API)

vc14

Alternatively, you can launch genconf, a GUI tool allowing to configure build options interactively. That tool will analyze your environment and propose you to choose available options:

  • Type and version of project files to generate (from the list of installed ones, detected by presence of environment variables like VS100COMNTOOLS on Windows platform).

  • Method to populate folder inc (short-cuts by default).

  • Location of third-party libraries (usually downloaded from OCCT web site, see above).

  • Path to common directory where third-party libraries are located (optional).

  • Paths to headers and binaries of the third-party libraries (found automatically basing on previous options; click button "Reset" to update).

  • Generation of PDB files within Release build ("Release with Debug info", false by default).

Below are screenshots of genconf tool on various platforms (Windows and Linux):

Click "Save" to store the specified configuration in custom.bat (Windows) or custom.sh (other systems) file.

Projects generation

Launch genproj to update content of inc folder and generate project files after changes in OCCT code affecting layout or composition of source files.

  • Note

    To use genproj and genconf tools you need to have Tcl installed and accessible by PATH. If Tcl is not found, the tool may prompt you to enter the path to directory where Tcl can be found.

$ genproj.bat

Note that if custom.bat is not present, genproj will start genconf to configure environment.

Building

Visual Studio

Launch msvc.bat to start Visual Studio with all necessary environment variables defined, and build the whole solution or required toolkits.

The MSVC project files are located in folders adm\msvc\vc.... Binaries are produced in win32 or win64 folders.

To start DRAW, launch draw.bat.

Code::Blocks

Code::Blocks is a cross-platform IDE which can be used for building OCCT on Linux, macOS and Windows platforms. The generated Code::Blocks project could be found within subfolder adm//cbp.

To start Code::Blocks, launch script codeblocks.sh. To build all toolkits, click Build->Build workspace in the menu bar.

To start DRAWEXE, which has been built with Code::Blocks on Mac OS X, run the script

./draw.sh cbp [d]

Option d is used if OCCT has been built in Debug mode.

XCode

XCode is an IDE for development on macOS platform and targeting macOS and iOS platforms. genproj tool comes with a legacy XCode project files generator, but CMake is a preferred way for building OCCT on macOS platform.

To start XCode, launch script xcode.sh. To build a certain toolkit, select it in Scheme drop-down list in XCode toolbar, press Product in the menu and click Build button.

To build the entire OCCT:

  • Create a new empty project (select File -> New -> Project -> Empty project in the menu; input the project name, e.g. OCCT; then click Next and Create).

  • Drag and drop the OCCT folder in the created OCCT project in the Project navigator.

  • Select File -> New -> Target -> Aggregate in the menu.

  • Enter the project name (e.g. OCCT) and click Finish. The Build Phases tab will open.

  • Click "+" button to add the necessary toolkits to the target project. It is possible to select all toolkits by pressing Command+A combination.

To start DRAWEXE, which has been built with XCode on Mac OS X, perform the following steps:

1.Open Terminal application 2.Enter <OCCT_ROOT_DIR>:

cd <OCCT_ROOT_DIR>

3.Run the script

./draw.sh xcd [d]

Option d is used if OCCT has been built in Debug mode.