Open bparvanov opened 20 hours ago
I think I fixed it. Switched from OpenGL 4.5 core to OpenGL 4.1 core on macOS. Other systems remain untouched. I wish apple stuff wouldn't be so expensive then i could test it myself.
Thank you, but now this happens:
System.TypeInitializationException: The type initializer for 'Hexa.NET.ImGui.Backends.SDL2.ImGuiImplSDL2' threw an exception. ---> System.DllNotFoundException: Unable to load shared library '/Users/borislav/Projects/Hexa.NET.KittyUI/ExampleMinimal/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplSDL2.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(/Users/borislav/Projects/Hexa.NET.KittyUI/ExampleMinimal/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplSDL2.dylib, 0x0001): Library not loaded: /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib Referenced from: <4484C004-9152-3921-B428-235D9000DB06> /Users/borislav/Projects/Hexa.NET.KittyUI/ExampleMinimal/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplSDL2.dylib Reason: tried: '/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file)
at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
at HexaGen.Runtime.LibraryLoader.LoadLibrary(LibraryNameCallback libraryNameCallback, LibraryExtensionCallback libraryExtensionCallback)
at Hexa.NET.ImGui.Backends.SDL2.ImGuiImplSDL2.InitApi()
at Hexa.NET.ImGui.Backends.SDL2.ImGuiImplSDL2..cctor()
--- End of inner exception stack trace ---
at Hexa.NET.ImGui.Backends.SDL2.ImGuiImplSDL2.SetCurrentContext(ImGuiContextPtr ctx)
at Hexa.NET.KittyUI.Windows.Window.Initialize(AppBuilder appBuilder) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Windows/Window.cs:line 76
at Hexa.NET.KittyUI.Application.RegisterWindow(IRenderWindow window) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Application.cs:line 104
at Hexa.NET.KittyUI.Windows.CoreWindow.Show() in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Windows/CoreWindow.cs:line 205
at Hexa.NET.KittyUI.Application.Run(IRenderWindow mainWindow, AppBuilder builder) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Application.cs:line 55
at Hexa.NET.KittyUI.AppBuilder.Run() in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/AppBuilder.cs:line 31
at Program.
Note that the file libImGuiImplSDL2.dylib does exist in the 'native' subfolder, but its dependency libSDL2-2.0.0.dylib does not
There is a similar file named libSDL2-2.0.dylib there.. if I rename it to libSDL2-2.0.0.dylib the same exception happens
By the way, FYI, today Apple announced the new Mac mini with M4 CPU... the cheapest model has 16GB RAM and costs $600
Try make a sym link from libSDL2-2.0.dylib to libSDL2-2.0.0.dylib and check again, if it works i will try making a patch tomorrow for it.
PS: libSDL2.dylib, libSDL2-2.0.dylib and libSDL2-2.0.0.dylib are all the same file and two are symlinks.
No change.. I think it looks for the file in the wrong place
dlopen(/Users/borislav/Projects/Hexa.NET.KittyUI/ExampleMinimal/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplSDL2.dylib, 0x0001): Library not loaded: /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib Referenced from: <4484C004-9152-3921-B428-235D9000DB06> /Users/borislav/Projects/Hexa.NET.KittyUI/ExampleMinimal/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplSDL2.dylib Reason: tried: '/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file), '/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib' (no such file)
Here are all the files located in the 'native' folder (after adding the symlink):
-rwxr--r--@ 1 borislav staff 3.7M Oct 27 21:23 cimgui.dylib -rwxr--r--@ 1 borislav staff 1.9M Oct 27 21:23 cimguizmo.dylib -rwxr--r--@ 1 borislav staff 2.0M Oct 27 21:23 cimnodes.dylib -rwxr--r--@ 1 borislav staff 5.8M Oct 27 21:23 cimplot.dylib -rwxr--r--@ 1 borislav staff 8.1M Oct 28 01:26 libDirectXTex.dylib -rwxr--r--@ 1 borislav staff 1.7M Oct 27 20:28 libImGuiImpl.dylib -rwxr--r--@ 1 borislav staff 1.7M Oct 27 20:35 libImGuiImplSDL2.dylib lrwxr-xr-x 1 borislav staff 17B Oct 29 20:12 libSDL2-2.0.0.dylib -> libSDL2-2.0.dylib -rwxr--r--@ 1 borislav staff 2.5M Oct 20 17:02 libSDL2-2.0.dylib -rwxr--r--@ 1 borislav staff 1.3M Oct 28 17:18 libopenal.dylib -rwxr--r--@ 1 borislav staff 618K Oct 28 12:55 libstbimage.dylib
It tries to load it from here "/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib"
my /opt folder is empty... if I recreate the whole path and copy the file to "/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib"
then the executable crashes:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_platform.dylib 0x18de6b7e0 _platform_strncmp + 176 1 libImGuiImplSDL2.dylib 0x12fe46960 ImGui_ImplSDL2_Init(SDL_Window, SDL_Renderer, void*) + 292 2 libImGuiImplSDL2.dylib 0x12fe4682c ImGui_ImplSDL2_InitForOpenGL + 36
I have absolutely no clue. But this could be a bigger issue could you test the glfw+opengl example in https://github.com/HexaEngine/Hexa.NET.ImGui
Yes, same issue there (can't find libImGuiImplGLFW.dylib's dependency - /opt/homebrew/opt/glfw/lib/libglfw.3.dylib):
System.DllNotFoundException: Unable to load shared library '/Users/borislav/Projects/Hexa.NET.ImGui/ExampleGLFWOpenGL3/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplGLFW.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable:
dlopen(/Users/borislav/Projects/Hexa.NET.ImGui/ExampleGLFWOpenGL3/bin/Debug/net8.0/runtimes/osx-arm64/native/libImGuiImplGLFW.dylib, 0x0001): Library not loaded: /opt/homebrew/opt/glfw/lib/libglfw.3.dylib
Referenced from:
at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath) at HexaGen.Runtime.LibraryLoader.LoadLibrary(LibraryNameCallback libraryNameCallback, LibraryExtensionCallback libraryExtensionCallback) at Hexa.NET.ImGui.Backends.GLFW.ImGuiImplGLFW.InitApi() in /Users/borislav/Projects/Hexa.NET.ImGui/Hexa.NET.ImGui.Backends.GLFW/Generated/FunctionTable.cs:line 28 at Hexa.NET.ImGui.Backends.GLFW.ImGuiImplGLFW..cctor()
Not sure if this stackoverflow question is related to our issue, but I'm sharing it anyway:
I found some more info on the topic:
When I call: otool -L libImGuiImplSDL2.dylib
It gives me: libImGuiImplSDL2.dylib: @rpath/libcimgui_impl.dylib (compatibility version 0.0.0, current version 0.0.0) /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib (compatibility version 3001.0.0, current version 3001.8.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1700.255.5) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)
What we need to do is make sure all of our .dylib do not use absolute paths for non-system dependencies. In this case libSDL2-2.0.0.dylib is a non-system library so we should not use absolute path for it.
This can be fixed using the install_name_tool like this:
install_name_tool -change /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib @rpath/libSDL2-2.0.0.dylib libImGuiImplSDL2.dylib
Now after we call "otool -L libImGuiImplSDL2.dylib" again, we get: libImGuiImplSDL2.dylib: @rpath/libcimgui_impl.dylib (compatibility version 0.0.0, current version 0.0.0) @rpath/libSDL2-2.0.0.dylib (compatibility version 3001.0.0, current version 3001.8.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1700.255.5) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)
Here is more info on @rpath: https://itwenty.me/posts/01-understanding-rpath/
Great now i just have to figure out how to set it in cmake. Good thing is that I can use darling for otool checking if it works.
I tried this: https://github.com/HexaEngine/cimgui_impl/blob/master/CMakeLists.txt#L194
I tried to run ExampleMinimal and the following exception throws:
System.InvalidOperationException: Context not created. at Hexa.NET.KittyUI.Windows.SdlContext.AssertCreated() in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Windows/SdlContext.cs:line 81 at Hexa.NET.KittyUI.Windows.SdlContext.SwapInterval(Int32 interval) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Windows/SdlContext.cs:line 165 at Hexa.NET.KittyUI.Windows.Window.Initialize(AppBuilder appBuilder) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Windows/Window.cs:line 75 at Hexa.NET.KittyUI.Application.RegisterWindow(IRenderWindow window) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Application.cs:line 103 at Hexa.NET.KittyUI.Windows.CoreWindow.Show() in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Windows/CoreWindow.cs:line 191 at Hexa.NET.KittyUI.Application.Run(IRenderWindow mainWindow, AppBuilder builder) in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/Application.cs:line 54 at Hexa.NET.KittyUI.AppBuilder.Run() in /Users/borislav/Projects/Hexa.NET.KittyUI/Hexa.NET.KittyUI/AppBuilder.cs:line 30 at Program.$(String[] args) in /Users/borislav/Projects/Hexa.NET.KittyUI/ExampleMinimal/Program.cs:line 9
I tested it on MacOS Sonoma 14.6.1, the CPU is M1 (ARM)