Skip to content

Compiling mujoco with MinGW fails because of redefined stat #3038

@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 stat is redefined.

[  9%] Building CXX object CMakeFiles/mujoco.dir/src/user/user_resource.cc.obj
/home/user/mujoco/src/user/user_resource.cc:36: error: "stat" redefined [-Werror]
   36 |   #define stat _stat
      | 
In file included from /home/user/mujoco/src/user/user_resource.cc:19:
/usr/share/mingw-w64/include/sys/stat.h:279: note: this is the location of the previous definition
  279 | #define stat _stat64
      | 
cc1plus: all warnings being treated as errors

I'd expect that it compiles without errors. This used to work with Mujoco 3.3.3.

As a workaround, I can comment out the define in line 36.

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

- [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.

Metadata

Metadata

Assignees

No one assigned

    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