Wednesday, August 27, 2014

Emscripten: Linking to boost libraries with CMake

On Linux, C++ Boost headers usually reside in /usr/include. However, when letting CMake automatically find those headers for you it ends up including "-i/usr/include" which contains all the system headers.

This results in all sorts of weird compilation errors since the emscripten headers must be used instead of the system headers. The errors are something like "sys/cdefs.h: not found" and "__gnuc_va_list is not valid".

The file "includes_CXX.rsp" in the cmake build directory contains all the includes being passed to the compiler and you can look at it to identify such mistakes.

My present workaround was:
1. Create a boost_includes folder in my home
2. Create a symlink to /usr/include/boost inside the boost_includes folder.
3. Add the environment variable: BOOST_INCLUDEDIR="/home/x/include/boost_includes"

This workaround is useful for any other library you need to link that resides in the system headers folders.

No comments:

Post a Comment