xmake-io / xmake-repo

📦 An official xmake package repository
https://xrepo.xmake.io
Apache License 2.0
698 stars 408 forks source link

packages(vulkansdk) not found - on M2 MacOS #2846

Open gabriellanzer opened 1 year ago

gabriellanzer commented 1 year ago

Xmake Version

2.8.5

Operating System Version and Architecture

macOS Sonoma 14.0

Describe Bug

Either running xrepo install vulkansdk or using add_requires("imgui v1.89.9-docking", {configs = {glfw_vulkan = true}}) in my xmake.lua cannot find the vulkansdk package:

error: The packages(vulkansdk) not found, please run xrepo update-repo first! error: execv(xmake require -j 10 --extra={system=false} vulkansdk) failed(255)

I tried running xrepo update-repo and updating xmake with xmake update to no avail. Is this package legacy? I can see it exists in the GitHub repo.

Expected Behavior

To be able to download and install vulkansdk package as it's in the Github repo.

Project Configuration

add_rules("plugin.vsxmake.autoupdate")
add_rules("plugin.compile_commands.autoupdate")

add_rules("mode.debug", "mode.release")

add_requires("glm 0.9.9+8", {alias = "glm"})
add_requires("glfw", "glad", "fmt", "glslang", "vulkan-headers", "volk")
add_requires("imgui v1.89.9-docking", {configs = {glfw_opengl3 = true, glfw_vulkan = true}})

target("MyProject-0.0.1")
    set_kind("binary")
    add_packages("glm", "imgui", "glfw", "glad", "fmt",
                 "glslang", "vulkan-headers", "volk")

    add_includedirs("src")

    add_headerfiles("src/**.h")

    add_files("src/**.cpp", "src/**.c*")

    set_languages("c++20")

    add_defines("USE_STL_LIB")
    -- add_defines("USE_EASTL_LIB");

    if is_mode("debug") then
        set_targetdir("bin/Debug/")
    elseif is_mode("release") then
        set_targetdir("bin/Release/")
    end
target_end()

Additional Information and Error Logs

No more information needed.

Latias94 commented 1 year ago

Have you install the vulkan sdk on your system? vulkansdk requires a manual installation with environment variable VULKAN_SDK set. check find_vulkansdk.lua

gabriellanzer commented 1 year ago

Yes! I have it installed and tried adding the SDK to the path. It doesn't look like find_vulkansdk.lua is doing proper checks for Apple... I will study it a little more during the week and might propose some adjustments.

gabriellanzer commented 1 year ago

I built xmake from source and I am trying to add a breakpoint following the debugging instructions but emmylua_debugger package is trying to hookup the x86_64 dsym...

xrepo env -b emmylua_debugger xrepo install vulkansdk
checking for platform ... macosx
checking for architecture ... arm64
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (arm64) ... 13.3
checking for Minimal target version of Xcode for macosx (arm64) ... 13.3
error: dlopen(/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib, 0x0006): tried: '/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib' (no such file), '/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
error: execv(xrepo install) failed(255)

Any idea on how to get it working so I can get more debug info? Or perhaps other commands? I tried copying the x86_64 symbol from the vscode extension to the package folder but the error was another one then (I can't recall which one).

I reckon that there is a specific folder inside the Vulkan SDK called macOS. In that folder I can find the folders bin, include, lib, source, etc. I tried pointing the SDK path to that folder but it still didn't work.

gabriellanzer commented 1 year ago

To be honest, I don't see why imgui would need vulkansdk, the vulkan-headers should suffice... I will try to work around this issue by creating a local repo and overriding imgui behavior to depend on the headers instead. If this works I imagine I can open a PR to submit the changes. Regardless of that, the vulkansdk is still complicated to get working.

waruqi commented 1 year ago

To be honest, I don't see why imgui would need vulkansdk, the vulkan-headers should suffice... I will try to work around this issue by creating a local repo and overriding imgui behavior to depend on the headers instead. If this works I imagine I can open a PR to submit the changes. Regardless of that, the vulkansdk is still complicated to get working.

you enabled vulkan config, {configs = {glfw_vulkan = true}}

Either running xrepo install vulkansdk or using add_requires("imgui v1.89.9-docking", {configs = {glfw_vulkan = true}}) in my xmake.lua cannot find the vulkansdk package:

https://github.com/xmake-io/xmake-repo/blob/2881c7612ffad5de53057938ee5bf6c7a84b6df7/packages/i/imgui/xmake.lua#L81

https://github.com/xmake-io/xmake-repo/blob/2881c7612ffad5de53057938ee5bf6c7a84b6df7/packages/i/imgui/port/xmake.lua#L36

waruqi commented 1 year ago

I built xmake from source and I am trying to add a breakpoint following the debugging instructions but emmylua_debugger package is trying to hookup the x86_64 dsym...

xrepo env -b emmylua_debugger xrepo install vulkansdk
checking for platform ... macosx
checking for architecture ... arm64
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (arm64) ... 13.3
checking for Minimal target version of Xcode for macosx (arm64) ... 13.3
error: dlopen(/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib, 0x0006): tried: '/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib' (no such file), '/Users/gkann/.xmake/packages/e/emmylua_debugger/1.6.3/99ef8b20e2c04f679c155dae63e8429e/bin/emmy_core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
error: execv(xrepo install) failed(255)

Any idea on how to get it working so I can get more debug info? Or perhaps other commands? I tried copying the x86_64 symbol from the vscode extension to the package folder but the error was another one then (I can't recall which one).

I reckon that there is a specific folder inside the Vulkan SDK called macOS. In that folder I can find the folders bin, include, lib, source, etc. I tried pointing the SDK path to that folder but it still didn't work.

you can add print logs to debug here.

https://github.com/xmake-io/xmake-repo/blob/2881c7612ffad5de53057938ee5bf6c7a84b6df7/packages/v/vulkansdk/xmake.lua#L22

https://github.com/xmake-io/xmake/blob/master/xmake/modules/detect/sdks/find_vulkansdk.lua

Latias94 commented 1 year ago

To be honest, I don't see why imgui would need vulkansdk, the vulkan-headers should suffice... I will try to work around this issue by creating a local repo and overriding imgui behavior to depend on the headers instead. If this works I imagine I can open a PR to submit the changes. Regardless of that, the vulkansdk is still complicated to get working.

you enabled vulkan config, {configs = {glfw_vulkan = true}}

Either running xrepo install vulkansdk or using add_requires("imgui v1.89.9-docking", {configs = {glfw_vulkan = true}}) in my xmake.lua cannot find the vulkansdk package:

https://github.com/xmake-io/xmake-repo/blob/2881c7612ffad5de53057938ee5bf6c7a84b6df7/packages/i/imgui/xmake.lua#L81

https://github.com/xmake-io/xmake-repo/blob/2881c7612ffad5de53057938ee5bf6c7a84b6df7/packages/i/imgui/port/xmake.lua#L36

Should we make imgui and cimgui depend on vulkan-headers instead of vulkansdk?

gabriellanzer commented 1 year ago

Thanks! What I mean by "I don't see why imgui would need vulkansdk" is that internally it doesn't seem to depend on anything that is not provided by vulkan-headers. So if the xmake.lua file for the imgui package would be changed to add_requires("vulkan-headers") instead of add_requires("vulkansdk") the dependencies would be less bloated.

waruqi commented 1 year ago

Thanks! What I mean by "I don't see why imgui would need vulkansdk" is that internally it doesn't seem to depend on anything that is not provided by vulkan-headers. So if the xmake.lua file for the imgui package would be changed to add_requires("vulkan-headers") instead of add_requires("vulkansdk") the dependencies would be less bloated.

You can try.

And idea? @AidanSun05 @Qudix

AidanSun05 commented 1 year ago

I tried installing a version of imgui that depended on vulkan-headers instead of vulkansdk. I could get it to install successfully, but when I tried to compile the example code with GLFW+Vulkan, I ran into "unresolved external symbol" linker errors because vulkan-headers only provides the Vulkan functions but not the SDK and the definitions (which vulkansdk does). While you can certainly remove the dependency on vulkansdk for imgui, you can't get rid of it completely in your project as it still provides libraries which you should link into.

gabriellanzer commented 1 year ago

Ah yes. I guess that makes sense... If you have your existing Vulkan application and you want to integrate ImGUI you wouldn't use their implementation. But that sort of defeated the purpose of having a fully functional package. Sorry for the misleading suggestion. I didn't have the time to debug MacOS further yet... I ended up copy-pasting the ImGui files instead.

SnowinterCat commented 11 months ago

Maybe you can try adding this line of code before all add_requires: add_requires("vulkansdk") Then try recompiling it.

If that doesn't work, change the name of the current project (e.g. Project to Project1), then create a new project called Project, then copy the original code and the modified xmake.lua and recompile it.

I couldn't find vulkansdk on Windows and ubuntu 20.04 before. it's because I added this line in xmake.lua: add_requires("vulkansdk", {configs = {shared = true}}) When I saw add_require("vulkansdk") don't take any parameter in other issues, I changed xmake.lua and still couldn't find vulkansdk.

but I created a new project and suddenly I found that the new project could find vulkansdk. That's what solved the problem.

I hope my previous manager and method can help you.