ubuntu20.04编译IfcOpenShell

键盘侠 2022年01月25日 1,345次浏览

1.安装依赖

sudo apt-get install git cmake gcc g++ libboost-all-dev libcgal-dev

2.以下任选一种安装OCCT包(如果源码编译安装,编译时间很长,可能需要花几个小时机器配置差的话,耐心等待)

a.使用系统源中自带的

sudo apt-get install libocct-data-exchange-dev libocct-draw-dev libocct-foundation-dev libocct-modeling-algorithms-dev libocct-modeling-data-dev libocct-ocaf-dev libocct-visualization-dev

b.获取最新的发布版本编译安装

https://dev.opencascade.org/release

c.从系统源中自带的oce软件包

sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev

d.从源码编译安装oce

$ sudo apt-get install libftgl-dev libtbb2 libtbb-dev libgl1-mesa-dev libfreetype6-dev
$ git clone https://github.com/tpaviot/oce.git
$ cd oce
$ mkdir build && cd build
$ cmake ..
$ make -j
$ sudo make install

3.源码编译安装COLLADA

$ sudo apt-get install libpcre3-dev libxml2-dev
$ git clone https://github.com/KhronosGroup/OpenCOLLADA.git
$ cd OpenCOLLADA
Using a known good revision, but HEAD should work too:
$ git checkout 064a60b65c2c31b94f013820856bc84fb1937cc6
$ mkdir build && cd build
$ cmake ..
$ make -j
$ sudo make install

4. 为IfcPython支持,添加依赖

$ sudo apt-get install python-all-dev swig

5.编译IfcOpenShell

$ cd /path/to/IfcOpenShell
$ mkdir build && cd build
$ cmake ../cmake -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ \
      -DOPENCOLLADA_INCLUDE_DIR="/usr/local/include/opencollada" \
      -DOPENCOLLADA_LIBRARY_DIR="/usr/local/lib/opencollada"  \
      -DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ \
      -DCGAL_INCLUDE_DIR=/usr/include \
      -DGMP_INCLUDE_DIR=/usr/include \
      -DMPFR_INCLUDE_DIR=/usr/include \
      -DGMP_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
      -DMPFR_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
      -DHDF5_SUPPORT=Off
$ make -j

一些主要的参数需要自己根据自己的系统来指定 ,包括OCC_INCLUDE_DIR,OPENCOLLADA_INCLUDE_DIR,OPENCOLLADA_LIBRARY_DIR,如果不需要COLLADA支持可以使用-DCOLLADA_SUPPORT=0参数来禁用。

6.安装

sudo make install