Skip to content

Export callback globals on Windows#3087

Open
Ashutosh0x wants to merge 1 commit intogoogle-deepmind:mainfrom
Ashutosh0x:fix/windows-callback-exports
Open

Export callback globals on Windows#3087
Ashutosh0x wants to merge 1 commit intogoogle-deepmind:mainfrom
Ashutosh0x:fix/windows-callback-exports

Conversation

@Ashutosh0x
Copy link
Copy Markdown
Contributor

This Pull Request fixes linkage issues on Windows where global callback variables were not being correctly exported in the MuJoCo DLL.

Changes

  • Added MJAPI to the definitions of mju_user_error, mju_user_warning, mju_user_malloc, and mju_user_free in engine_util_errmem.c.
  • Added MJAPI to the definitions of mjcb_* variables in engine_callback.c.

This ensures these symbols are included in the .lib import library, allowing them to be used by researchers using Rust or other non-MSVC toolchains on Windows.

Fixes #3060

On Windows, global variables like mju_user_* and mjcb_* must be explicitly exported with __declspec(dllexport) in their definitions to be included in the import library (.lib).

This change adds the MJAPI macro to these definitions, fixing linkage errors in non-MSVC environments (like Rust or MinGW).

Fixes google-deepmind#3060
@yuvaltassa
Copy link
Copy Markdown
Collaborator

This looks like the correct fix, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows libraries don't expose mju_user_* and mjcb_* symbols

2 participants