Skip to content

Assimp compilation

Olivier Michel edited this page May 25, 2022 · 21 revisions

This page explains how to recompile the Assimp dependency on every platforms. Assimp is used internally in Webots to import mesh assets.

Windows

On Windows, assimp is provided as a MSYS2 pacman package and is automatically installed when installing the msys dependencies.

Linux & Mac

Compilation of the latest Assimp version

git clone https://github.com/assimp/assimp
cd assimp
git checkout v5.2.3
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=RELEASE \
-DASSIMP_BUILD_TESTS=OFF \
-DASSIMP_NO_EXPORT=ON \
-DASSIMP_BUILD_COLLADA_IMPORTER=ON \
-DASSIMP_BUILD_OBJ_IMPORTER=ON \
-DASSIMP_BUILD_STL_IMPORTER=ON \
-DASSIMP_BUILD_FBX_IMPORTER=ON \
-DASSIMP_BUILD_3DS_IMPORTER=OFF \
-DASSIMP_BUILD_BLEND_IMPORTER=OFF \
-DASSIMP_BUILD_DXF_IMPORTER=OFF \
-DASSIMP_BUILD_BVH_IMPORTER=OFF \
-DASSIMP_BUILD_OGRE_IMPORTER=OFF \
-DASSIMP_BUILD_X3D_IMPORTER=OFF \
-DASSIMP_BUILD_AMF_IMPORTER=OFF \
-DASSIMP_BUILD_AC_IMPORTER=OFF \
-DASSIMP_BUILD_ASE_IMPORTER=OFF \
-DASSIMP_BUILD_ASSBIN_IMPORTER=OFF \
-DASSIMP_BUILD_B3D_IMPORTER=OFF \
-DASSIMP_BUILD_CSM_IMPORTER=OFF \
-DASSIMP_BUILD_HMP_IMPORTER=OFF \
-DASSIMP_BUILD_IRRMESH_IMPORTER=OFF \
-DASSIMP_BUILD_IRR_IMPORTER=OFF \
-DASSIMP_BUILD_LWO_IMPORTER=OFF \
-DASSIMP_BUILD_LWS_IMPORTER=OFF \
-DASSIMP_BUILD_MD2_IMPORTER=OFF \
-DASSIMP_BUILD_MD3_IMPORTER=OFF \
-DASSIMP_BUILD_MD5_IMPORTER=OFF \
-DASSIMP_BUILD_MDC_IMPORTER=OFF \
-DASSIMP_BUILD_MDL_IMPORTER=OFF \
-DASSIMP_BUILD_NFF_IMPORTER=OFF \
-DASSIMP_BUILD_NDO_IMPORTER=OFF \
-DASSIMP_BUILD_OFF_IMPORTER=OFF \
-DASSIMP_BUILD_OPENGEX_IMPORTER=OFF \
-DASSIMP_BUILD_PLY_IMPORTER=OFF \
-DASSIMP_BUILD_MS3D_IMPORTER=OFF \
-DASSIMP_BUILD_COB_IMPORTER=OFF \
-DASSIMP_BUILD_IFC_IMPORTER=OFF \
-DASSIMP_BUILD_XGL_IMPORTER=OFF \
-DASSIMP_BUILD_Q3D_IMPORTER=OFF \
-DASSIMP_BUILD_Q3BSP_IMPORTER=OFF \
-DASSIMP_BUILD_RAW_IMPORTER=OFF \
-DASSIMP_BUILD_SIB_IMPORTER=OFF \
-DASSIMP_BUILD_SMD_IMPORTER=OFF \
-DASSIMP_BUILD_TERRAGEN_IMPORTER=OFF \
-DASSIMP_BUILD_3D_IMPORTER=OFF \
-DASSIMP_BUILD_X_IMPORTER=OFF \
-DASSIMP_BUILD_GLTF_IMPORTER=OFF \
-DASSIMP_BUILD_3MF_IMPORTER=OFF \
-DASSIMP_BUILD_MMD_IMPORTER=OFF \
-DASSIMP_BUILD_MMD_IMPORTER=OFF \
-DASSIMP_BUILD_ASSIMP_TOOLS=OFF \
-DASSIMP_BUILD_TESTS=OFF \
-DASSIMP_BUILD_ZLIB=TRUE \
-S .. -B .

then

make -j12

On macOS you will need to add to cmake:

-DCMAKE_OSX_ARCHITECTURES=arm64\;x86_64 \
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11 \

Create the package

tar -cvjSf assimp.tar.bz2 assimp/include/assimp assimp/build/include/assimp/config.h assimp/build/code/*dylib assimp/build/code/*so

Troubleshooting

If the compilation fails due to zlib, the following patch might be necessary. Return to assimp's root folder and run:

patch -ulbf code/Common/ZipArchiveIOSystem.cpp << EOF
@@ -198,3 +198,5 @@
     mapping.zopen_file = (open_file_func)open;
+#ifdef ZOPENDISK64
     mapping.zopendisk_file = (opendisk_file_func)opendisk;
+#endif
     mapping.zread_file = (read_file_func)read;
EOF

Then follow the above procedure once more.

WebotsJS

When upgrading the version of assimp, it is also important to recompile assimpjs.

This can be done by following this procedure:

Clone this wiki locally