apicici / cimgui-love

LÖVE module for Dear ImGui obtained by wrapping cimgui with LuaJIT FFI.
MIT License
76 stars 6 forks source link

[Troubleshooting] Can't get cimgui-love set up on an m1 mac #14

Closed javi7 closed 1 year ago

javi7 commented 1 year ago

I have not been able to get my love project to successfully load with cimgui-love.

Some googling told me this might mean a mismatch between the LOVE version targeted in cimgui.dylib and my project, but I don't think this is the case. I'm running LOVE 11.4.

Any suggestions for how to troubleshoot this?

apicici commented 1 year ago

It seems like the pre-compiled release only works on x64 architectures.

The version you were able to compile yourself should work, but it seems that, when you are trying to load cimgui, lua is attempting to open the shared library directly (by searching for the luaopen_cimgui symbol, which is not there). Can you try having the same folder structure as the release but replacing the dylib with the one you compiled?

javi7 commented 1 year ago

I got it working now. I totally forgot to include the rest of the release directory 🤦 . Thank you for catching my mistake!

apicici commented 1 year ago

Was the original error that you got also in the scenario in which the other files are missing? It would be useful to know if indeed the library needs to be recompiled to use it on the M1.

javi7 commented 1 year ago

I just re-tested with both versions of cimgui.dylib (the original one in the releases file and the one I built on my m1) and it original one throws the same error even when all the files are present. When I use the version built on my m1, it works as expected. So, I think it will be necessary to recompile the library for use on an M1.

apicici commented 1 year ago

Thanks for testing. I'll look into building a version that works on M1.

apicici commented 1 year ago

@javi7 I set up appveyor to build a universal dylib that should work on both x64 and arm64. Could you test if the new release works?

javi7 commented 1 year ago

I just tried this out and it initially crashed my game due to a system security policy.

a prompt that popped up: image

the error in the command line:

Error: cimgui/init.lua:10: dlopen(cimgui/cimgui.dylib, 0x0005): tried: '/Applications/love.app/Contents/MacOS/../Frameworks/cimgui/cimgui.dylib' (no such file), '/Applications/love.app/Contents/MacOS/../Frameworks/cimgui/cimgui.dylib' (no such file), 'cimgui/cimgui.dylib' (code signature in <32213599-5520-3E06-B141-8167B83783C1> '/Users/javiermuhrer/things/whalin/cimgui/cimgui.dylib' not valid for use in process: library load disallowed by system policy), '/Users/javiermuhrer/things/whalin/cimgui/cimgui.dylib' (code signature in <32213599-5520-3E06-B141-8167B83783C1> '/Users/javiermuhrer/things/whalin/cimgui/cimgui.dylib' not valid for use in process: library load disallowed by system policy)

I was able to circumvent that by ctrl-clicking the .dylib file in Finder and opening it with the terminal. By opening it this way, it prompted me to approve the file which I assume added it to a safelist or something. When I subsequently re-ran my game, I didn't get any errors. However, the calls into cimgui are not working as expected. I have my game set up to show the imgui demo window. It works with the library I built manually, but it doesn't work with the universal library I just downloaded. Nothing appears in-game.

javi7 commented 1 year ago

Actually, this does work after circumventing the error. With both versions of the library, I have an issue where the imgui windows sometimes don't show in my program. I suspect this is an unrelated issue in my own game.

apicici commented 1 year ago

Thanks for testing it! I think the problem with the security policy is caused by the fact that I'm now using Xcode to compile the library. I guess it's ok if the library is used for development, but if it's meant to be shipped with a game it would need to be recompiled and signed.