veldrid icon indicating copy to clipboard operation
veldrid copied to clipboard

Unable to find entry point named "objc_msgSend_stret" in shared library '/usr/lib/libobjc.A.dylib For Apple Silicon Based Macs

Open enumouse opened this issue 3 years ago • 8 comments

When running on macOS (2021 M1 Pro) an exception error is raised, with the details: "Unable to find entry point named "objc_msgSend_stret" in shared library '/usr/lib/libobjc.A.dylib"

Tested it on my old PC (Windows) with no issues so is Mac related.

enumouse avatar Jan 11 '23 16:01 enumouse

what macOS version are you running?

Eeveelution avatar Jan 11 '23 20:01 Eeveelution

MacOS Ventura 13.1

enumouse avatar Jan 11 '23 21:01 enumouse

I checked my usr/lib/ folder and I cannot seem to find libobjc.A.dylib.

That is likely the issue but I have no idea how to manually get the file to put it there, or if you even need that file there in new versions of MacOS

enumouse avatar Jan 11 '23 21:01 enumouse

Any updates on how to fix this?

enumouse avatar Jan 15 '23 16:01 enumouse

I believe the fix here should be the same as what was done in this commit). The short answer is that objc_msgSend_stret just shouldn't be used in this codepath on M1 processors. The longer answer is that the code already has some notion of whether the stret function variants should be used, but it's not handled very consistently (see this function and the places it is used), and it doesn't take processor arch into account (thus the TODO marker there...).

If anyone with an M1 processor is able to test the quick fix (e.g. the same thing that @frenzibyte did in the commit above), I'd be happy to merge it in.

mellinoe avatar Jan 17 '23 22:01 mellinoe

Also, it would help to know what stack trace you see when you get this exception. Is this still a problem in the latest version of the code?

mellinoe avatar Jan 17 '23 22:01 mellinoe

That not fixed. stack is

Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named 'objc_msgSend_stret' in shared library '/usr/lib/libobjc.A.dylib'. at Veldrid.MetalBindings.ObjectiveCRuntime.objc_msgSend_stret(Void* retPtr, IntPtr receiver, Selector selector) at Veldrid.MetalBindings.ObjectiveCRuntime.objc_msgSend_stret[T](IntPtr receiver, Selector selector) at Veldrid.MetalBindings.NSView.get_frame() at Veldrid.MTL.MTLSwapchain..ctor(MTLGraphicsDevice gd, SwapchainDescription& description) at Veldrid.MTL.MTLGraphicsDevice..ctor(GraphicsDeviceOptions options, Nullable`1 swapchainDesc) at Veldrid.GraphicsDevice.CreateMetal(GraphicsDeviceOptions options, SwapchainDescription swapchainDescription) at Veldrid.StartupUtilities.VeldridStartup.CreateMetalGraphicsDevice(GraphicsDeviceOptions options, Sdl2Window window, Boolean colorSrgb) at Veldrid.StartupUtilities.VeldridStartup.CreateMetalGraphicsDevice(GraphicsDeviceOptions options, Sdl2Window window) at Veldrid.StartupUtilities.VeldridStartup.CreateGraphicsDevice(Sdl2Window window, GraphicsDeviceOptions options, GraphicsBackend preferredBackend) at Veldrid.StartupUtilities.VeldridStartup.CreateWindowAndGraphicsDevice(WindowCreateInfo windowCI, GraphicsDeviceOptions deviceOptions, GraphicsBackend preferredBackend, Sdl2Window& window, GraphicsDevice& gd) at Veldrid.StartupUtilities.VeldridStartup.CreateWindowAndGraphicsDevice(WindowCreateInfo windowCI, GraphicsDeviceOptions deviceOptions, Sdl2Window& window, GraphicsDevice& gd) at ImGuiNET.Program.Main(String[] args) in /Users/Midstream/Documents/Dev/C#/Other/ImGui.NET/src/ImGui.NET.SampleProgram/Program.cs:line 39

lkj01010 avatar Oct 18 '23 20:10 lkj01010

@lkj01010 Are you sure you're running latest version of Veldrid? This path is impossible to reach for M1/M2-based machines: https://github.com/veldrid/veldrid/blob/63b6300f7da014214452dd6ea9a6653ff202bd67/src/Veldrid.MetalBindings/NSView.cs#L26-L34

frenzibyte avatar Oct 21 '23 23:10 frenzibyte