Intro
Hi!
I am a researcher at AICOR, I use MuJoCo for my research.
Build log excerpt
Key part:
40%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_api.cc.o
[ 40%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_cache.cc.o
[ 42%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_composite.cc.o
[ 42%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_flexcomp.cc.o
[ 42%] Building C object CMakeFiles/mujoco.dir/src/user/user_init.c.o
[ 43%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_mesh.cc.o
[ 43%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_model.cc.o
In file included from /media/giangnguyen/Storage/Ubuntu2004/Multiverse-MuJoCo-Connector/src/mujoco-3.5.0/src/user/user_model.cc:57:
/media/giangnguyen/Storage/Ubuntu2004/Multiverse-MuJoCo-Connector/src/mujoco-3.5.0/src/user/user_threadpool.h:72:3: error: ‘constinit’ does not name a type
72 | constinit static thread_local int worker_id_;
| ^~~~~~~~~
/media/giangnguyen/Storage/Ubuntu2004/Multiverse-MuJoCo-Connector/src/mujoco-3.5.0/src/user/user_threadpool.h: In static member function ‘static int mujoco::user::ThreadPool::WorkerId()’:
/media/giangnguyen/Storage/Ubuntu2004/Multiverse-MuJoCo-Connector/src/mujoco-3.5.0/src/user/user_threadpool.h:42:34: error: ‘worker_id_’ was not declared in this scope; did you mean ‘WorkerId’?
42 | static int WorkerId() { return worker_id_; }
| ^~~~~~~~~~
| WorkerId
make[2]: *** [CMakeFiles/mujoco.dir/build.make:695: CMakeFiles/mujoco.dir/src/user/user_model.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:642: CMakeFiles/mujoco.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
-- Install configuration: "Release"
CMake Error at build/mujoco-3.5.0/simulate/cmake_install.cmake:46 (file):
file INSTALL cannot find
"/media/giangnguyen/Storage/Ubuntu2004/Multiverse-MuJoCo-Connector/build/mujoco-3.5.0/bin/simulate":
No such file or directory.
Call Stack (most recent call first):
build/mujoco-3.5.0/cmake_install.cmake:102 (include)
My setup
- OS: Ubuntu 20.04
- Compiler:
cc: GNU 9.4.0
c++: GNU 9.4.0
- CMake: 4.0.0
- MuJoCo version:
3.5.0
- Build type:
Release
What's happening? What did you expect?
I was building MuJoCo 3.5.0 from source, it fails during compilation with GCC 9.4.0. The error is:
src/user/user_threadpool.h:72:3: error: ‘constinit’ does not name a type
72 | constinit static thread_local int worker_id_;
| ^~~~~~~~~
...
src/user/user_threadpool.h:42:34: error: ‘worker_id_’ was not declared in this scope
42 | static int WorkerId() { return worker_id_; }
| ^~~~~~~~~~
This blocks building the mujoco target, and the subsequent install step also fails because simulate was not produced.
Expected behavior
MuJoCo should compile successfully (or fail early with a clear message) on supported toolchains, or CMake should enforce a minimum C++ standard/compiler that supports constinit.
Actual behavior
Compilation fails with ‘constinit’ does not name a type in src/user/user_threadpool.h, causing the entire build to fail.
After the compile failure, cmake --install additionally errors:
file INSTALL cannot find ".../bin/simulate": No such file or directory.
Notes / suspicion
constinit is a C++20 feature. This looks like either:
- MuJoCo now requires C++20 (or a newer GCC), but the minimum compiler/C++ standard is not enforced at configure time, or
- This should be guarded / replaced for older compilers (e.g., GCC 9.x).
If MuJoCo requires C++20, it would be helpful if CMake produced a clear error (e.g., “C++20 required; GCC >= X or Clang >= Y”) instead of failing mid-build.
Additional info
- Building with
-DMUJOCO_BUILD_SIMULATE=ON
- Dependencies were fetched via
FetchContent (qhull, tinyxml2, tinyobjloader, ccd, glfw3) and those built successfully before the failure.
Steps for reproduction
Steps to reproduce
- Configure and build with:
cmake -S "$MUJOCO_SRC_DIR" -B "$BUILD_DIR" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DMUJOCO_BUILD_EXAMPLES=OFF \
-DMUJOCO_BUILD_TESTS=OFF \
-DMUJOCO_BUILD_SIMULATE=ON \
-DMUJOCO_TEST_PYTHON_UTIL=OFF \
-DCMAKE_POLICY_VERSION_MINIMUM="3.5" \
-Wno-deprecated -Wno-dev
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR"
- Build fails around ~43% when compiling
src/user/user_model.cc.
Minimal model for reproduction
No response
Code required for reproduction
No response
Confirmations
Intro
Hi!
I am a researcher at AICOR, I use MuJoCo for my research.
Build log excerpt
Key part:
My setup
cc: GNU 9.4.0c++: GNU 9.4.03.5.0ReleaseWhat's happening? What did you expect?
I was building MuJoCo
3.5.0from source, it fails during compilation with GCC 9.4.0. The error is:This blocks building the
mujocotarget, and the subsequent install step also fails becausesimulatewas not produced.Expected behavior
MuJoCo should compile successfully (or fail early with a clear message) on supported toolchains, or CMake should enforce a minimum C++ standard/compiler that supports
constinit.Actual behavior
Compilation fails with
‘constinit’ does not name a typeinsrc/user/user_threadpool.h, causing the entire build to fail.After the compile failure,
cmake --installadditionally errors:Notes / suspicion
constinitis a C++20 feature. This looks like either:If MuJoCo requires C++20, it would be helpful if CMake produced a clear error (e.g., “C++20 required; GCC >= X or Clang >= Y”) instead of failing mid-build.
Additional info
-DMUJOCO_BUILD_SIMULATE=ONFetchContent(qhull, tinyxml2, tinyobjloader, ccd, glfw3) and those built successfully before the failure.Steps for reproduction
Steps to reproduce
src/user/user_model.cc.Minimal model for reproduction
No response
Code required for reproduction
No response
Confirmations