melonDS-emu / melonDS

DS emulator, sorta
https://melonds.kuribo64.net
GNU General Public License v3.0
3.27k stars 542 forks source link

Compiling and attempting to run on Intel macOS Big Sur 11.3.1: kLSNoExecutableErr #1124

Open dalchen opened 3 years ago

dalchen commented 3 years ago

I've followed the steps to compile from source. After running the cmake commands I got the following output near the end:

[100%] Linking CXX executable ../../../melonDS.app/Contents/MacOS/melonDS
ld: warning: dylib (/usr/local/lib/libSDL2.dylib) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/lib/libglib-2.0.dylib) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/Cellar/libarchive/3.5.1_1/lib/libarchive.dylib) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/opt/qt/lib/QtOpenGLWidgets.framework/Versions/A/QtOpenGLWidgets) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/lib/libepoxy.dylib) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/opt/qt/lib/QtWidgets.framework/Versions/A/QtWidgets) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/opt/qt/lib/QtOpenGL.framework/Versions/A/QtOpenGL) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/opt/qt/lib/QtGui.framework/Versions/A/QtGui) was built for newer macOS version (11.0) than being linked (10.15)
ld: warning: dylib (/usr/local/opt/qt/lib/QtCore.framework/Versions/A/QtCore) was built for newer macOS version (11.0) than being linked (10.15)
Bundling macOS libraries...
[100%] Built target melonDS

(Note the warnings with macOS Big Sur vs. Catalina)

I then tried to open the app via open melonDS.app in the terminal and got:

The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10827 "kLSNoExecutableErr: The executable is missing" UserInfo={_LSLine=3691, _LSFunction=_LSOpenStuffCallLocal}

However, when I ran sudo open melonDS.app, I get no output in the terminal and I see the macOS dock make space for it and then the space suddenly disappears.

I can run the melonDS 0.9.2 downloaded from the web fine if that helps. This issue is just with compiling and running from source. Thanks!

Head commit: e3b4350f44a51d0012457a556dc04dfd0ba267d4 OS: macOS 11.3.1 Architecture: Intel

endrift commented 3 years ago

What happens if you try running ./melonDS.app/Contents/MacOS/melonDS?

dalchen commented 3 years ago

I get a segfault:

[1]    19901 segmentation fault  ./melonDS.app/Contents/MacOS/melonDS

I also tried running it in lldb and got the following:

* thread #1, stop reason = EXC_BAD_ACCESS (code=1, address=0xd07718a4c)
    frame #0: 0x00000001074e5471 dyld`ImageLoaderMachOClassic::bindIndirectSymbolPointers(ImageLoader::LinkContext const&, bool, bool) + 403
dyld`ImageLoaderMachOClassic::bindIndirectSymbolPointers:
->  0x1074e5471 <+403>: movb   0x4(%rsi,%rax), %cl
    0x1074e5475 <+407>: andb   $0xe, %cl
    0x1074e5478 <+410>: movl   -0x30(%rbp), %edx
    0x1074e547b <+413>: cmpb   $0xe, %cl
Target 0: (melonDS) stopped.
(lldb) bt
* thread #1, stop reason = EXC_BAD_ACCESS (code=1, address=0xd07718a4c)
  * frame #0: 0x00000001074e5471 dyld`ImageLoaderMachOClassic::bindIndirectSymbolPointers(ImageLoader::LinkContext const&, bool, bool) + 403
    frame #1: 0x00000001074e558b dyld`ImageLoaderMachOClassic::doBind(ImageLoader::LinkContext const&, bool, ImageLoader const*) + 87
    frame #2: 0x00000001074db59d dyld`ImageLoader::recursiveBind(ImageLoader::LinkContext const&, bool, bool, ImageLoader const*) + 253
    frame #3: 0x00000001074db566 dyld`ImageLoader::recursiveBind(ImageLoader::LinkContext const&, bool, bool, ImageLoader const*) + 198
    frame #4: 0x00000001074cce0b dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 8529
    frame #5: 0x00000001074c5224 dyld`dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 450
    frame #6: 0x00000001074c5025 dyld`_dyld_start + 37
RayyanAnsari commented 3 years ago

Do the builds from the CI work for you? (Click on the "macOS" badge in the README.)

dalchen commented 3 years ago

I gave https://dev.azure.com/melonDS/melonDS/_build/results?buildId=174&view=artifacts&pathAsName=false&type=publishedArtifacts a shot (the .dmg image for f94b784), and it looks like I got the same error again:

Process:               melonDS [4682]
Path:                  /Volumes/VOLUME/*/melonDS.app/Contents/MacOS/melonDS
Identifier:            net.kuribo64.melonDS
Version:               0.9.2 (0.9.2)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           melonDS [4682]
User ID:               501

Date/Time:             2021-06-07 13:40:32.541 -0700
OS Version:            macOS 11.3.1 (20E241)
Report Version:        12
Bridge OS Version:     5.3 (18P4556)
Anonymous UUID:        C7A9874F-330C-C57A-F54E-0C6419881A3C

Sleep/Wake UUID:       6454F78B-2A1F-4F0A-A587-7959A4FF219C

Time Awake Since Boot: 10000 seconds
Time Since Wake:       1000 seconds

System Integrity Protection: enabled

Notes:                 Translocated Process

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000d0c4b0a3c
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [4682]

VM Regions Near 0xd0c4b0a3c:
    __LINKEDIT                  1168f5000-1168f8000    [   12K] r--/r-- SM=NUL  /usr/lib/dyld
--> 
    STACK GUARD              7ffee6d4a000-7ffeea54a000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0

Application Specific Information:
dyld: launch, loading dependent libraries
/private/var/folders/x5/7w0bdkqd33j10p276tgjqxgw0000gn/T/AppTranslocation/75F3D63A-DB5E-4410-BD2F-E991B580D5D2/d/melonDS.app/Contents/MacOS/../Frameworks/libslirp.0.dylib

Thread 0 Crashed:
0   dyld                            0x0000000116801471 ImageLoaderMachOClassic::bindIndirectSymbolPointers(ImageLoader::LinkContext const&, bool, bool) + 403
1   dyld                            0x000000011680158b ImageLoaderMachOClassic::doBind(ImageLoader::LinkContext const&, bool, ImageLoader const*) + 87
2   dyld                            0x00000001167f759d ImageLoader::recursiveBind(ImageLoader::LinkContext const&, bool, bool, ImageLoader const*) + 253
3   dyld                            0x00000001167f7566 ImageLoader::recursiveBind(ImageLoader::LinkContext const&, bool, bool, ImageLoader const*) + 198
4   dyld                            0x00000001167e8e0b dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 8529
5   dyld                            0x00000001167e1224 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 450
6   dyld                            0x00000001167e1025 _dyld_start + 37
RayyanAnsari commented 3 years ago

What happens if you build without -DMACOS_BUNDLE_LIBS=ON?

dalchen commented 3 years ago

What happens if you build without -DMACOS_BUNDLE_LIBS=ON?

Same issue happens

CatGreen90 commented 3 years ago

I gave https://dev.azure.com/melonDS/melonDS/_build/results?buildId=174&view=artifacts&pathAsName=false&type=publishedArtifacts a shot (the .dmg image for f94b784), and it looks like I got the same error again:

I get this same error on Catalina trying to run that build (all builds from https://github.com/Arisotura/melonDS/commit/21f54774500659d95b0f8e24a80f8a3495c876a3 on, actually; older ones work fine).

dalchen commented 3 years ago

OK I finally got it working via combining everyone's advice above:

  1. Make sure HEAD is f94b784c4d0f2eace8e985f8edc53084666d203a
  2. At project root folder, mkdir build && cd build
  3. Run the following command:
    cmake .. -DCMAKE_PREFIX_PATH="$(brew --prefix qt@6);$(brew --prefix libarchive)" -DUSE_QT6=ON
    make -j$(sysctl -n hw.logicalcpu)

    (Note the missing -DMACOS_BUNDLE_LIBS=ON which is different than the command in the README)

  4. Run open melonDS.app, this will give me the kLSNoExecutableErr error above
  5. Run lldb melonDS.app and enter r to run it, this will show the following lines:
    (lldb) r
    Process 10786 launched: '/Users/dalchen/melonDS/build/melonDS.app/Contents/MacOS/melonDS' (x86_64)
    melonDS 0.9.2
    http://melonds.kuribo64.net/
    2021-06-08 00:28:54.717307-0700 melonDS[10786:379036] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=10786
    2021-06-08 00:28:54.717398-0700 melonDS[10786:379036] SecTaskCopyDebugDescription: melonDS[10786]/0#-1 LF=0
    2021-06-08 00:28:55.153370-0700 melonDS[10786:379036] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=10786
    2021-06-08 00:28:55.153448-0700 melonDS[10786:379036] SecTaskCopyDebugDescription: melonDS[10786]/0#-1 LF=0
    2021-06-08 00:28:55.302736-0700 melonDS[10786:379036] [qt.gui.imageio] libpng warning: iCCP: known incorrect sRGB profile

    But it will now run properly.

  6. Now if you run open melonDS.app it'll work fine.

I have no idea why running it in the debugger fixed it after building without the bundle libs flag. Either way, thank you all for the support!

joonhyungshin commented 2 years ago

I'm working on macOS 12.1. To me, simply removing -DMACOS_BUNDLE_LIBS=ON solved without the debugger thing. Thank you!