Open main menu

Humanoid Robots Wiki β

Changes

Mujoco WASM Build From Source

15 bytes removed, 22:29, 22 July 2024
no edit summary
As of this writing, you'd need to disable several features of 3.1.6 to allow for a successful WASM build.
For example in <pre>CMakeLists.txt</pre>, the options to build examples, simulate library, and tests for MuJoCo have been turned off by default (changed from ON to OFF). New configurations and target properties for building MuJoCo with Emscripten have been added. This includes defining source files, checking their existence, and setting specific properties and options for building WebAssembly (.wasm) and HTML output. Some target link options have been adjusted, including removing the lodepng library from the target link list.
In * `src/user/user_objects.cc`, comment out the line that includes `lodepng.h`. Replace the bodies of the `mjCHField::LoadPNG` and `mjCTexture::LoadPNG` functions with a single return statement.* In * `src/engine/engine_util_errmem.c`, update the preprocessor condition in the `mju_writeLog` function by replacing `__STDC_VERSION_TIME_H__` with `__EMSCRIPTEN__` in the `#if` directive. The line should now include `__EMSCRIPTEN__` in the condition.* In * `src/engine/engine_crossplatform.h`, add a conditional block specifically for Emscripten within the preprocessor directive. Inside this block, include the `sort_r.h` header and define the `mjQUICKSORT` and `quicksortfunc` macros appropriately. This will separate the handling for Apple, Emscripten, and other platforms.* In the * `cmake/MujocoOptions.cmake` file, remove the `-Wno-int-in-bool-context` compiler warning flag from the list of warnings.
In the `CMakeLists.txt` file, make the following changes:
emmake make
</syntaxhighlight>
 
 
=== Notes ===
* Ensure that the Emscripten environment is correctly activated before starting the build process.
* Regularly clean the build directory to maintain a clean build environment.