Building libassimp

33 views
Skip to first unread message

キャロウ マーク

unread,
Feb 27, 2020, 2:48:25 AM2/27/20
to emscripten-discuss
I am trying to build libassimp with Emscripten. I don’t believe there is a port. If there is, I’d be delighted.

I started with

emconfigure cmake ../assimp

and got

System LLVM compiler cannot be used to build with Emscripten! Check
Emscripten's LLVM toolchain location in .emscripten configuration file, and
make sure to point CMAKE_C_COMPILER to where emcc is located.

I thought emconfigure was supposed to set up the cross-compilation tool chain. What did I do wrong?

I then tried

cmake -D CMAKE_C_COMPILER=/Users/mark/Projects/github/emsdk/upstream/emscripten/emcc -D ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=No -D ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=No -D ASSIMP_BUILD_OBJ_IMPORTER ../assimp

which seemed to work, giving only warnings about not being able to build a shared library so building a static library and not finding “rt”. However there are no make files. The directory has only CMakeCache.txt and the directory CMakeFiles.

Regards

-Mark
signature.asc

Floh

unread,
Feb 27, 2020, 8:04:42 AM2/27/20
to emscripten-discuss
I think it's not enough to provide a different compiler path to cmake, since this is a cross-compiling scenario, so a whole cmake-toolchian is needed.

The emscripten SDK has one under "cmake/Modules/Platform/Emscripten.cmake", but trying assimp via (e.g.):

cmake -DCMAKE_TOOLCHAIN_FILE=~/scratch/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake ..

...creates a Makefile, but then fails to compile (looks like some configuration problem).

Using my own cmake-toolchain file (part of fips here: https://github.com/floooh/fips/blob/master/cmake-toolchains/emscripten.toolchain.cmake) compilation goes pretty far (lots of warnings though), until it bails out in glTFExporter.cpp:

/Users/floh/projects/fips-assimp/assimp/code/glTFExporter.cpp:585:35: error: ordered comparison between pointer and zero ('aiVector3D *'
      (aka 'aiVector3t<float> *') and 'int')
                if(comp_allow && (aim->mNormals > 0)) idx_srcdata_normal = b->byteLength;// Store index of normals array.

...so it looks like it's not done with a simple cross-compile, but needs some code changes too to be compatible with latest clang.

There's an open ticket in the assimp repo about emscripten-cmake support:


Might be worth pinging there.

Cheers,
-Floh.
Reply all
Reply to author
Forward
0 new messages