2022-08-29 11:40:38 +10:00
Installation
============
2022-08-29 16:25:17 +10:00
If you'd like to work with the C++ core of IfcOpenShell, these guides will show
you how to compile and install IfcOpenShell.
.. note ::
It is not necessary to compile IfcOpenShell if you only want to use
IfcOpenShell-Python, IfcConvert, or the other utilities such as IfcClash or
IfcDiff. Compilation is only necessary for C++ developers.
2024-02-06 14:16:52 +05:00
By default, it will compile all available IFC schemas. To reduce compilation time you can specify
only the schemas you need in `CMakeLists.txt` with `set(SCHEMA_VERSIONS "2x3" "4")` .
2022-08-29 11:40:38 +10:00
You will need:
- `Git <https://git-scm.com/> `__
2024-02-06 11:58:40 +05:00
- `CMake <https://cmake.org/> `__ (3.21 or newer)
2022-08-29 11:40:38 +10:00
IfcOpenShell depends on:
- `Boost <http://www.boost.org/> `__
2022-09-01 09:07:40 +10:00
- `OpenCascade <https://dev.opencascade.org/> `__ - for building IfcGeom For
2024-07-15 14:18:22 +05:00
converting IFC representation items into BRep solids and tessellated meshes.
Officially v7.5.0 is supported. Other versions may have unexpected behaviour.
2022-08-29 11:40:38 +10:00
- (Optional) `OpenCOLLADA <https://github.com/khronosGroup/OpenCOLLADA/> `__ -
for IfcConvert to be able to write tessellated Collada (.dae) files
- (Optional) `SWIG <http://www.swig.org/> `__ and `Python
<https://www.python.org/>`__ - for building the IfcOpenShell Python interface
and use in the BlenderBIM Add-on
- (Optional) `HDF5 <https://www.hdfgroup.org/solutions/hdf5> `__ - for caching
geometry using the HDF5 format
Compiling on Linux
------------------
The following instructions are for Ubuntu, modify as required for other
operating systems. GCC (4.7 or newer) or Clang (any version) is required.
.. seealso ::
The `nix/build-all.py <https://github.com/IfcOpenShell/IfcOpenShell/tree/master/nix/build-all.py> `__
script can be experimented with and studied for pointers for other operating
systems. Note that this script is not currently meant to be used for a
typical IfcOpenShell workspace setup.
1. Fetch the latest source code, including all submodules.
2024-06-21 18:28:52 +05:00
.. code-block:: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
git clone --recursive https://github.com/IfcOpenShell/IfcOpenshell.git
2022-08-29 11:40:38 +10:00
.. warning::
The path where the source code is cloned to can contain spaces but non-ASCII
characters are very likely to cause problems with the build.
2. Install basic dependencies:
2024-06-21 18:28:52 +05:00
.. code-block:: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
sudo apt-get install git cmake gcc g++ libboost-all-dev libcgal-dev
2022-08-29 11:40:38 +10:00
2024-08-02 04:59:09 +02:00
The CGAL version that ships with Ubuntu 20.04 is too old. Users on Ubuntu 20.04 are advised to manually install CGAL 5.3.
2024-07-15 14:18:22 +05:00
3. Install OpenCascade Technology (OCCT).
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block:: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
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
2022-08-29 11:40:38 +10:00
.. seealso::
2022-09-03 20:16:33 +10:00
If OCCT is not available, an alternative is to `manually compile OCCT
2022-08-29 11:40:38 +10:00
<https://dev.opencascade.org/release>`__.
2024-08-02 04:59:09 +02:00
IfcOpenShell 0.8 depends on fairly recent OCCT additions such as the BVH Tree functionality. Users on Ubuntu 20.04 are advised to manually compile and install OCCT 7.7.
2022-09-03 20:16:33 +10:00
Another alternative is to use OpenCascade Community Edition (OCE), but it may
lag behind OCCT and is no longer actively maintained so is not recommended.
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev
2022-08-29 11:40:38 +10:00
2022-09-03 20:16:33 +10:00
As a final alternative, you may also manually compile OCE:
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
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 ..
2022-08-29 11:40:38 +10:00
# Replace X with number of CPU cores + 1
2024-06-21 18:28:52 +05:00
make -j X
sudo make install
2022-08-29 11:40:38 +10:00
2022-09-03 20:16:33 +10:00
.. warning ::
Choose one option only between installing OCCT, installing OCE, or
self-compilation. If you install and compile multiple versions of
OpenCascade, your system may get confused.
2022-09-08 17:23:29 +02:00
4. For building IfcConvert with COLLADA (.dae) support (ON by default), OpenCOLLADA is needed:
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
sudo apt-get install libpcre3-dev libxml2-dev
git clone https://github.com/KhronosGroup/OpenCOLLADA.git
cd OpenCOLLADA
2022-08-29 11:40:38 +10:00
# Using a known good revision, but HEAD should work too:
2024-06-21 18:28:52 +05:00
git checkout 064a60b65c2c31b94f013820856bc84fb1937cc6
mkdir build && cd build
cmake ..
2022-08-29 11:40:38 +10:00
# Replace X with number of CPU cores + 1
2024-06-21 18:28:52 +05:00
make -j X
sudo make install
2022-08-29 11:40:38 +10:00
2022-09-08 17:23:29 +02:00
5. For building the IfcPython wrapper (ON by default), SWIG and Python development are needed:
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
sudo apt-get install python-all-dev swig
2022-08-29 11:40:38 +10:00
2022-09-08 17:23:29 +02:00
6. For building support for HDF5 caching (ON by default), install dependencies:
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
sudo apt-get install libhdf5-dev libaec-dev zlibc
2022-08-29 11:40:38 +10:00
7. Compile IfcOpenShell itself.
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
cd /path/to/IfcOpenShell
mkdir build && cd build
2022-08-29 11:40:38 +10:00
# Customise the compile options to suit your environment
# Check all paths are valid for your environment
2024-06-21 18:28:52 +05:00
cmake ../cmake \
2022-08-29 11:40:38 +10:00
-DOCC_LIBRARY_DIR= /usr/lib/x86_64-linux-gnu/ \
2024-08-02 04:59:09 +02:00
-DOCC_INCLUDE_DIR= /usr/include/opencascade \
\
2022-08-29 11:40:38 +10:00
# Optional Collada support
2023-08-29 09:04:42 +02:00
-DCOLLADA_SUPPORT= On \
2022-08-29 11:40:38 +10:00
-DOPENCOLLADA_INCLUDE_DIR= "/usr/local/include/opencollada" \
-DOPENCOLLADA_LIBRARY_DIR= "/usr/local/lib/opencollada" \
-DPCRE_LIBRARY_DIR= /usr/lib/x86_64-linux-gnu/ \
2024-08-02 04:59:09 +02:00
\
2022-08-29 11:40:38 +10:00
# Optional HDF5 support
2023-08-29 09:04:42 +02:00
-DHDF5_SUPPORT= On \
2022-08-29 11:40:38 +10:00
-DHDF5_LIBRARIES= "/usr/local/hdf5/lib/libhdf5_cpp.so;/usr/local/hdf5/lib/libhdf5.so;/usr/lib64/libz.so;/usr/lib64/libsz.so;/usr/lib64/libaec.so" \
-DHDF5_INCLUDE_DIR= "/usr/local/hdf5/include" \
2024-08-02 04:59:09 +02:00
\
2022-08-29 11:40:38 +10:00
-DCGAL_INCLUDE_DIR= /usr/include \
-DGMP_INCLUDE_DIR= /usr/include \
-DMPFR_INCLUDE_DIR= /usr/include \
-DGMP_LIBRARY_DIR= /usr/lib/x86_64-linux-gnu \
2024-08-02 04:59:09 +02:00
-DMPFR_LIBRARY_DIR= /usr/lib/x86_64-linux-gnu \
-DJSON_INCLUDE_DIR= /usr/include \
-DEIGEN_DIR= /usr/include/eigen3
2024-08-02 05:02:20 +02:00
# Replace X with number of CPU cores + 1. Reduce when running out of memory. Compiling the code generated from the schemas is resource intensive.
2024-06-21 18:28:52 +05:00
make -j X
2022-08-29 11:40:38 +10:00
# Optionally install to the system
2024-06-21 18:28:52 +05:00
sudo make install
2022-08-29 11:40:38 +10:00
Compiling on MacOS
------------------
GCC (4.7 or newer) or Clang (any version) is required.
1. Fetch the latest source code, including all submodules.
2024-06-21 18:28:52 +05:00
.. code-block:: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
git clone --recursive https://github.com/IfcOpenShell/IfcOpenshell.git
2022-08-29 11:40:38 +10:00
.. warning::
The path where the source code is cloned to can contain spaces but non-ASCII
characters are very likely to cause problems with the build.
2. Install all dependencies using `Homebrew <https://brew.sh/> `__
2024-06-21 18:28:52 +05:00
.. code-block:: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
brew install boost cmake python3 cgal ftgl gmp libaec opencascade swig hdf5 zlib
2022-09-08 17:23:29 +02:00
# homebrew automatically links most libraries, except some keg-only ones
2024-06-21 18:28:52 +05:00
brew link zlib --force
2022-08-29 11:40:38 +10:00
2022-09-08 17:23:29 +02:00
3. Build IfcOpenShell with flags for Homebrew dependencies: (`` /usr/local/ `` ) for Intel machines with x84_64 architecture,
(`` /opt/homebrew/ `` ) for Apple Silicon processors with arm64 architecture.
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
.. code-block :: bash
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
cd /path/to/IfcOpenShell
mkdir build && cd build
2022-09-13 18:06:08 +02:00
# set library flags
2024-06-21 18:28:52 +05:00
export LDFLAGS = " $LDFLAGS -Wl,-flat_namespace,-undefined,suppress "
cmake ../cmake \
2022-09-08 17:23:29 +02:00
-DPYTHON_EXECUTABLE= /opt/homebrew/bin/python3.10 \
-DPYTHON_LIBRARY= /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib \
-DPYTHON_INCLUDE_DIR= /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10/ \
-DOCC_LIBRARY_DIR= /opt/homebrew/lib/ \
-DOCC_INCLUDE_DIR= /opt/homebrew/include/opencascade/ \
-DCGAL_INCLUDE_DIR= /opt/homebrew/include/ \
-DGMP_LIBRARY_DIR= /opt/homebrew/lib/ \
2023-08-29 09:04:42 +02:00
-DMPFR_LIBRARY_DIR= /opt/homebrew/lib/ \
2022-09-08 17:23:29 +02:00
-DHDF5_LIBRARY_DIR= /opt/homebrew/lib/ \
-DHDF5_INCLUDE_DIR= /opt/homebrew/include/ \
2023-08-29 09:04:42 +02:00
-DCOLLADA_SUPPORT= 0
2022-09-13 18:06:08 +02:00
# `sysctl -n hw.ncpu` returns the number of cpu cores on macOS
2024-06-21 18:28:52 +05:00
make -j$( sysctl -n hw.ncpu)
2022-08-29 11:40:38 +10:00
Compiling on Windows (Visual Studio)
------------------------------------
This is for users of `Visual Studio <https://www.visualstudio.com/> `__ 2008 to
2019 (2022 not yet supported by dependency CMake) with C++ toolset (or `Visual
C++ Build Tools <http://landinghub.visualstudio.com/visual-cpp-build-tools>`__).
1. Fetch the latest source code, including all submodules.
2024-06-21 18:28:52 +05:00
.. code-block:: bat
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
git clone --recursive https://github.com/IfcOpenShell/IfcOpenshell.git
2022-08-29 11:40:38 +10:00
.. warning::
The path where the source code is cloned to can contain spaces but non-ASCII
characters are very likely to cause problems with the build.
2. Assuming Visual Studio 2015 x64 environment variables set, build dependencies
and run cmake.
2024-06-21 18:28:52 +05:00
.. code-block :: bat
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
cd IfcOpenShell\win
build-deps.cmd
run-cmake.bat
2022-08-29 11:40:38 +10:00
3. Open and build the solution file in Visual Studio:
2024-06-21 18:28:52 +05:00
.. code-block :: bat
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
..\build-vs2015-x64\IfcOpenShell.sln
2022-08-29 11:40:38 +10:00
As the scripts default to using the `` RelWithDebInfo `` configuration, and a
freshly created solution by CMake defaults to `` Debug `` , make sure to switch the
used build configuration. Build the `` INSTALL `` project (right-click -> Project
Only) to deploy the headers and binaries into a single location if
wanted/needed.
Alternatively, one can use the utility batch file(s) to build and install the
project easily from the command-line (installing a project will build it
also, if required):
2024-06-21 18:28:52 +05:00
.. code-block :: bat
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
install-ifcopenshell.bat
2022-08-29 11:40:38 +10:00
.. seealso ::
For more information on configuring a Windows compilation see the `Windows
Readme
2024-06-27 11:45:05 +10:00
<https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/win/readme.md>`__.
2022-08-29 11:40:38 +10:00
Compiling on Windows (MSYS2 + MinGW)
------------------------------------
This is for users of `MSYS2 <https://msys2.github.io/> `__ and `MinGW
<https://www.mingw-w64.org/> `__.
1. Fetch the latest source code, including all submodules.
2024-06-21 18:28:52 +05:00
.. code-block:: bat
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
git clone --recursive https://github.com/IfcOpenShell/IfcOpenshell.git
2022-08-29 11:40:38 +10:00
.. warning::
The path where the source code is cloned to can contain spaces but non-ASCII
characters are very likely to cause problems with the build.
2. Start the MSYS2 Shell and then:
2024-06-21 18:28:52 +05:00
.. code-block:: bat
2022-08-29 11:40:38 +10:00
2024-06-21 18:28:52 +05:00
cd IfcOpenShell/win
./build-deps.sh
./run-cmake.sh
./install-ifcopenshell.sh
2022-08-29 11:40:38 +10:00
.. seealso ::
For more information on configuring a Windows compilation see the `Windows
Readme
2024-06-27 11:45:05 +10:00
<https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/win/readme.md>`__.
2022-08-30 23:00:11 +10:00
Packaged installation
---------------------
- **Arch Linux** : `Direct from Git <https://aur.archlinux.org/packages/ifcopenshell-git/> `__ .