Skip to content

Compiling mujoco with MinGW fails because of thread-safe localtime #3037

@maximilian-maisel-bl

Description

@maximilian-maisel-bl

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 it doesn't recognize thread safe localtime implementation.

[  6%] Building C object CMakeFiles/mujoco.dir/src/engine/engine_util_errmem.c.obj
/home/user/mujoco/src/engine/engine_util_errmem.c: In function ‘mju_writeLog’:
/home/user/mujoco/src/engine/engine_util_errmem.c:107:6: error: #error "Thread-safe version of `localtime` is not present in the standard C library"
  107 |     #error "Thread-safe version of `localtime` is not present in the standard C library"
      |      ^~~~~
make[2]: *** [CMakeFiles/mujoco.dir/build.make:532: CMakeFiles/mujoco.dir/src/engine/engine_util_errmem.c.obj] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:1457: CMakeFiles/mujoco.dir/all] Fehler 2
make: *** [Makefile:146: all] Fehler 2

I'd expect that it compiles without errors.

As a workaround, add a || 1 to line 110 #elif _MSC_VER or comment out the block that gets localtime and logs it.

Steps for reproduction

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions