Issue with Fortran Binding to Mujoco

I have written a Fortran interface to Mujoco’s C API but it is not working properly. I cannot see the problem so I hope I can get some help to review and diagnose the issue. The Fortran binding is here.

The problem is that on running a simple test, I get a blank screen and then a ‘not responding’ pop up a few seconds later, like so:

What I should get is:

To reproduce the problem (the repository for the Fortran binding interface is here):

  • The src folder consists of the Fortran interfaces to the C api (the C header files are in src/c_api). So, for example, the file src/mod_mjmodel corresponds to the file src/c_api/mjmodel.h.

  • The relevant Mujoco libraries are placed in the folder mujoco_libs. So, all you need to do is ensure they can be found when building.
    You will also require libGL and libglfw.

  • In line 52 in app/main_mujoco_test.f90, you need to replace the:


with the path to ball.xml, which is in the folder src/assets/ball.xml

  • Then just run with: fpm run test_mujoco.

Thanks in advance.