lionheart-remake icon indicating copy to clipboard operation
lionheart-remake copied to clipboard

Add sc68 macos support

Open jerellsworth opened this issue 3 years ago • 14 comments

Expected Behavior

Running java -Xverify:none -XX:+UseParallelGC -Xmx256m -Xms256m -Dsun.java2d.uiScale=1.0 -jar lionheart-remake-pc-1.0.0.jar launches the program

Actual Behavior

Error message starting with Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'sc68'

Steps to Reproduce the Problem

Extract on Macos (I'm running Mojave) and run the above command.

I also ran brew install sc68 before launching java. Homebrew did install the library, but it didn't fix the problem

Specifications

  • Lionheart Remake Version: 1.0.0
  • JRE: 16.0.1
  • OS: MacOS Mojave

BTW This also showed up on SO https://stackoverflow.com/questions/59534141/file-libsc68-dylib-is-missing

jerellsworth avatar Jul 02 '21 21:07 jerellsworth

Just to try if this works:

  • open the JAR, extract linux-x86-64 folder somewhere
  • rename extracted folder to darwin-x86-64
  • rename (inside folder) libsc68.so to libsc68.dylib
  • put this new folder inside the JAR

DjThunder avatar Jul 03 '21 07:07 DjThunder

Thanks for looking into this! Unfortunately, that didn't work either (assuming I'm doing this right)

$ unzip lionheart-remake-pc-1.0.0.jar -d lionheart
$ cd lionheart
$ mv linux-x86-64/ darwin-x86-64
$ cd darwin-x86-64/
$ mv libsc68.so libsc68.dylib
$ cd ../..
$ jar cMf lionheart-remake-darwin.jar -C lionheart .
$ java -Xverify:none -XX:+UseParallelGC -Xmx256m -Xms256m -Dsun.java2d.uiScale=1.0 -jar lionheart-remake-darwin.jar

error message was:

Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
7/3/21, 10:37 AM    INFO: Starting "LionEngine "10.0.0" for "Lionheart Remake 1.0.0"
7/3/21, 10:37 AM    INFO: Class resources = com.b3dgs.lionheart.AppLionheart
Exception in thread "main" com.b3dgs.lionengine.LionEngineException: Error on loading SC68 Library: sc68
	at com.b3dgs.lionengine.audio.sc68.Sc68Format.loadLibrary(Sc68Format.java:79)
	at com.b3dgs.lionengine.audio.sc68.Sc68Format.<init>(Sc68Format.java:107)
	at com.b3dgs.lionheart.AppLionheart.main(AppLionheart.java:42)
Caused by: java.lang.UnsatisfiedLinkError: dlopen(/Users/me/Library/Caches/JNA/temp/jna7628144770551454083.tmp, 9): no suitable image found.  Did find:
	/Users/me/Library/Caches/JNA/temp/jna7628144770551454083.tmp: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
	/Users/me/Library/Caches/JNA/temp/jna7628144770551454083.tmp: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
	at com.sun.jna.Native.open(Native Method)
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:461)
	at com.sun.jna.Library$Handler.<init>(Library.java:192)
	at com.sun.jna.Native.load(Native.java:596)
	at com.sun.jna.Native.load(Native.java:570)
	at com.b3dgs.lionengine.audio.sc68.Sc68Format.getLibrary(Sc68Format.java:90)
	at com.b3dgs.lionengine.audio.sc68.Sc68Format.loadLibrary(Sc68Format.java:75)
	... 2 more

jerellsworth avatar Jul 03 '21 15:07 jerellsworth

Ok so I need to compile it on Mac... I re-uploaded the release, you can download it, it will no longer fail, simply silent music.

DjThunder avatar Jul 03 '21 15:07 DjThunder

Thanks! Where can I download the new version? I think the one the README links to is still the old version.

Also, if you don't have a Mac handy I can try to compile sc68 on my end. It would be helpful if you could let me know how you build it for Linux, since it wasn't obvious to me how you build this library from just poking around https://github.com/Zeinok/sc68

jerellsworth avatar Jul 03 '21 16:07 jerellsworth

Use same link, I just repackaged the same with failsafe library loading. Everything is here about sc68: https://github.com/b3dgs/sc68

DjThunder avatar Jul 03 '21 16:07 DjThunder

running your configure command in https://github.com/b3dgs/sc68/blob/master/README.md and then make in https://sourceforge.net/projects/sc68/ succeeded in building an executable binary, but I can't find a shared library. Is there a weird make target or something?

jerellsworth avatar Jul 03 '21 22:07 jerellsworth

Yes because you also need to compile PortAudio as SC68 (whose are raw library) And then compile the code in my repo (aggregating SC68 and PortAudio to build audio routine as external library). Note: I used eclipse CDT (it just need to import existing project and build, I did not generated makefile...)

This will build THE dynamic library from PortAudio and SC68 static library.

DjThunder avatar Jul 04 '21 07:07 DjThunder

I compiled it for win 32bits.

DjThunder avatar Jul 19 '21 06:07 DjThunder

@jerellsworth Do you have free time for this task ? I can't make Mac compilation (even virtual machines don't work on my computer with this OS).

What need to be done is

  • Compile original sc68 with target x86_64-pc-linux-gnu mac equivalent (darwin-x86-64) ../../../sc68-svn/sc68/configure --without-ao --enable-static --disable-shared CFLAGS=-fPIC
  • Same with PortAudio (../../svn/configure --enable-static --disable-shared CFLAGS=-fPIC)
  • Static lib will be in Release folder
  • Compile sc68_player.c and .h targeting mac (with eclipse if you can, as everything is configured with)

DjThunder avatar Aug 25 '21 18:08 DjThunder

@DjThunder A little bit of progress here:

I was able to configure sc68 and PortAudio. PortAudio required the additional flag --disable-mac-universal.

I attempted to just run make and it worked after running mkdir src/hostapi/skeleton/, but it looks like that only compiles libportaudio.la. sc68's library is absent.

I then attempted to build in eclipse, and got the error: Error: Program "armv7a-linux-androideabi22-clang" not found in PATH PATH=[/usr/bin:/bin:/usr/sbin:/sbin:/home/djthunder/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin]. Maybe there's a way to turn off the android target?

jerellsworth avatar Sep 01 '21 01:09 jerellsworth

  • Hum, right click on project
  • Properties
  • C/C++ build
  • Manage configurations (top right)
  • Delete android configuration, and maybe win (but I don't understand why it searches android tools, maybe you ran a full build with all profiles ?)

Thanks a lot for your time !

DjThunder avatar Sep 01 '21 20:09 DjThunder

@jerellsworth Did it worked ?

DjThunder avatar Oct 19 '21 10:10 DjThunder

I tried to cross compile, but I'm stuck with missing CoreAudio/CoreAudio.h, of course (portaudio part).

DjThunder avatar Nov 06 '21 22:11 DjThunder

@jerellsworth Hello, were you able to test something ? It would be great to make it work on macos for the next release :)

DjThunder avatar Feb 07 '22 21:02 DjThunder