google-deepmind / google-deepmind/mujoco
Compiling mujoco with MinGW fails because of unrecognized printf formats
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
### Intro
I'm compiling Mujoco for different targets in a Linux-based CI.
### My setup
- Ubuntu 24.04 amd64
- Mujoco 3.4.0
### What's happening? What did you expect?
Building Mujoco with MinGW fails because of using the unsupported "%z" printf format.
```
[ 9%] Building CXX object CMakeFiles/mujoco.dir/src/thread/thread_pool.cc.obj
/home/user/mujoco/src/thread/thread_pool.cc: In function ‘mujoco::mjStackInfo* mujoco::mju_getStackInfoForThread(mjData*, size_t)’:
/home/user/mujoco/src/thread/thread_pool.cc:202:47: error: unknown conversion type character ‘z’ in format [-Werror=format=]
202 | mju_error("Arena is not large enough for %zu shards", number_of_shards);
| ^
/home/user/mujoco/src/thread/thread_pool.cc:202:15: error: too many arguments for format [-Werror=format-extra-args]
202 | mju_error("Arena is not large enough for %zu shards", number_of_shards);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/mujoco/src/thread/thread_pool.cc: In function ‘void mujoco::ConfigureMultiThreadedStack(mjData*)’:
/home/user/mujoco/src/thread/thread_pool.cc:242:111: error: unknown conversion type character ‘z’ in format [-Werror=format=]
242 | mju_error("mj_bindThreadPool: sharding stack - existing stack larger than shard size: current_size = %zu, "
| ^
/home/user/mujoco/src/thread/thread_pool.cc:243:32: error: unknown conversion type character ‘z’ in format [-Werror=format=]
243 | "max_size = %zu", current_limit, (uintptr_t) end_shard_cursor_ptr);
| ^
/home/user/mujoco/src/thread/thread_pool.cc:242:19: error: too many arguments for format [-Werror=format-extra-args]
242 | mju_error("mj_bindThreadPool: sharding stack - existing stack larger than shard size: current_size = %zu, "
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243 | "max_size = %zu", current_limit, (uintptr_t) end_shard_cursor_ptr);
| ~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
```
I'd expect that it compiles without errors.
As a workaround, I can comment out the problematic `mju_error` calls.
### Steps for reproduction
* Building Mujoco with mingw:
`cmake -DCMAKE_TOOLCHAIN_FILE=~/cmake-toolchain-mingw64-x86_64.cmake -DCMAKE_COMPILE_WARNING_AS_ERROR=false ..`
* Remove problematic section from `mujoco.rc` file (Issue #839)
* Comment out the `localtime` issue #3037
* Workaournd stat issue #3038
* Run `make`
This is the content of the toolchain file:
```
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
find_program(CMAKE_C_LINKER NAMES x86_64-w64-mingw32-ld)
find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc)
find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++)
```
### Minimal model for reproduction
This bug is independent of the model and code.
### Code required for reproduction
This bug is independent of the model and code.
### Confirmations
- [x] I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting.
- [x] I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before.
Contributor guide
Assessment
This issue has not been assessed yet.