Skip to content

macOS non-bundle build cannot load Vulkan #1563

Open
@neebyA

Description

@neebyA

Current Behavior

When building Cemu on Mac, the build with default settings is not able to launch games, while the bundled (option -DMACOS_BUNDLE=ON) is. I looked through the logs and found this:

[18:02:47.090] Vulkan loader not available.
[18:02:49.817] Vulkan cant list devices because Vulkan loader failed

It looks like the MoltenVK library is not able to be found. I looked to find what the bundle does differently and found this:

Cemu/src/CMakeLists.txt

Lines 109 to 114 in f801fc1

add_custom_command (TARGET CemuBin POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy "/usr/local/lib/libMoltenVK.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${LIBUSB_PATH}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_SOURCE_DIR}/src/resource/update.sh" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/update.sh"
COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}"
COMMAND bash -c "install_name_tool -change ${LIBUSB_PATH} @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}")

This copies the libMoltenVK dylib into the Frameworks directory, and adds the directory to the runtime path.

So far, I've tried adding

  find_library(MOLTENVK_LIB MoltenVK)
  if(MOLTENVK_LIB)
    target_link_libraries(CemuCafe PRIVATE ${MOLTENVK_LIB})
  endif()

to this block, as well as setting LDFLAGS to -L/opt/homebrew/opt/molten-vk/lib -lMoltenVK, and confirmed with otool that the dylib appears in the load commands:

Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 80
         name /opt/homebrew/opt/molten-vk/lib/libMoltenVK.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1.0.0
compatibility version 1.0.0

However, this still has not worked.

The following workarounds have succeeded:

  1. Using the app bundle with -DMACOS_BUNDLE=ON
  2. Adding a new runtime path to the binary with install_name_tool -add_rpath /opt/homebrew/lib bin/Cemu_release
  3. Symlinking the dylib into the existing rpath: ln -s /opt/homebrew/Cellar/molten-vk/1.3.0/lib/libMoltenVK.dylib build/vcpkg_installed/arm64-osx/lib/

Any ideas for a way to resolve this through cmake instead of manually?

Expected Behavior

The Mac non-bundle build should be able to launch games with the Vulkan renderer

Steps to Reproduce

  1. Follow the macOS build steps: https://github.com/cemu-project/Cemu/blob/main/BUILD.md#build-cemu-using-cmake
  2. Launch the ./bin/Cemu_release executable
  3. Navigate to Options->General Settings->Graphics and observe the only available Graphics API is OpenGL

System Info (Optional)

OS: macOS 15.4.1
GPU: Apple M4

Emulation Settings (Optional)

No response

Logs (Optional)

log.txt

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