Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to compile libopenal.so for arm (Linux) #158

Closed
huangguiniab opened this issue Jan 2, 2021 · 15 comments
Closed

how to compile libopenal.so for arm (Linux) #158

huangguiniab opened this issue Jan 2, 2021 · 15 comments

Comments

@huangguiniab
Copy link

i try openal-soft ,but this can't work

@SWinxy
Copy link

SWinxy commented Jan 3, 2021

LWJGL2 is no longer being maintained. You should probably be looking for LWJGL3.

ARM was not a supported target for this project. LWJGL3 supports Linux ARM32/64 variants, however it doesn't yet support ARM Macs natively.

@r58Playz
Copy link

Is there a third party build.xml for LWJGL2 for arm64? I am trying to run MC 1.12 on arm64.

@huangguiniab
Copy link
Author

LWJGL2 is no longer being maintained. You should probably be looking for LWJGL3.

ARM was not a supported target for this project. LWJGL3 supports Linux ARM32/64 variants, however it doesn't yet support ARM Macs natively.

Sorry, I am not a game developer. I just want to run a lower version of Minecraft on my Raspberry Pi. It is not compatible with lwjgl3. I modified the build.xml to try to compile lwjgl2 for arm, but the game can run normally, but Could not initialize sound system

@huangguiniab
Copy link
Author

Is there a third party build.xml for LWJGL2 for arm64? I am trying to run MC 1.12 on arm64.

IMG_20210114_011852.jpg

mod /platform_build/linux_ant/build.xml 7-8 line

Game Minecraft 1.12 can use the output library to run normally

But no have libopenal.so output, the sound system cannot be initialized

@huangguiniab
Copy link
Author

The openal that comes with the operating system cannot be used because there is no function related to lwjgl, and the reference will directly cause the game to crash

@r58Playz
Copy link

r58Playz commented Jan 15, 2021

Oh sorry, I should have been more detailed. I am talking about macOS arm64. Is there any way to mod the current macOS build.xml?

@huangguiniab
Copy link
Author

Oh sorry, I should have been more detailed. I am talking about macOS arm64. Is there any way to mod the current macOS build.xml?

uhhhhh, I don’t have a Mac, but I think the code is too old, maybe the compiler toolchain doesn’t support it

Try it in /platform_build/macosx-ant/build.xml
param name="cflags"
param name="linkerflags"
Try changing the'-arch x86_64' to'-arch aarch64'

I think it might not work

@r58Playz
Copy link

r58Playz commented Jan 19, 2021

I tried that and now I get:

    [apply] clang: warning: no such sysroot directory: '${sdkroot}' [-Wmissing-sysroot]
    [apply] /Users/toshitchawda/Programming/lwjgl/src/native/macosx/context.m:40:9: fatal error: 'CoreFoundation/CoreFoundation.h' file not found
    [apply] #import <CoreFoundation/CoreFoundation.h>
    [apply]         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [apply] 1 error generated.

I have XCode though which has this header.

edit: I fixed that issue and another one in which it couldn't find jni.h, but now I get this:

    [apply] /Users/toshitchawda/Programming/lwjgl/src/native/macosx/context.m:105:11: error: implicit declaration of function 'CGDisplayBitsPerPixel' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    [apply]                                 bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
    [apply]                                       ^
    [apply] /Users/toshitchawda/Programming/lwjgl/src/native/macosx/context.m:107:10: error: implicit declaration of function 'CGDisplayBitsPerPixel' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    [apply]                         bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
    [apply]                               ^
    [apply] 2 errors generated.

more info:

     [echo]         Compiler: clang
     [echo]       Mac OS SDK: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
     [echo] JavaVM.framework: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

I am on macOS Big Sur.
Weird, since this is an ObjC file not a normal c file that clang is complaining about.
edit 2: Here's the modded build.xml:

<project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
	<property name="native" location="../../src/native"/>

	<target name="init">
		<mkdir dir="x86_64"/>
		<property environment="env" />
		<!-- Ask Xcode for correct path to XCode tools -->
		<!-- Will fail if XCode Command Line Tools are not installed on 10.7+ (Lion) -->
		<exec executable="xcode-select" outputproperty="developer_path" errorproperty="xcode-select.error" failonerror="false" failifexecutionfails="false">
			<arg value="-print-path" />
		</exec>
		<!-- Default to /Developer if xcode-select fails -->
		<condition property="developer_path" value="/Developer">
			<isset property="xcode-select.error" />
		</condition>

		<property name="sdk_path" value="Platforms/MacOSX.platform/Developer/SDKs"/>
		<property name="jvm_headers_path" value="System/Library/Frameworks/JavaVM.framework/Versions/A/Headers"/>

		<!-- Choose a JavaVM.framework -->
		<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.15.sdk">
			<and>
				<not><isset property="javavmroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.15.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers" type="dir"/>
			</and>
		</condition>
		<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
			<and>
				<not><isset property="javavmroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk/${jvm_headers_path}" type="dir"/>
			</and>
		</condition>
		<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
			<and>
				<not><isset property="javavmroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk/${jvm_headers_path}" type="dir"/>
			</and>
		</condition>
		<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
			<and>
				<not><isset property="javavmroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk/${jvm_headers_path}" type="dir"/>
			</and>
		</condition>
		<condition property="javavmroot" value=""> <!-- Old location -->
			<and>
				<not><isset property="javavmroot"/></not>
				<available file="/${jvm_headers_path}" type="dir"/>
			</and>
		</condition>

		<!-- Choose a MacOSX SDK -->
		<property name="compiler" value="clang"/> <!-- Default to clang for 10.8 and up -->

		<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.15.sdk">
			<and>
				<not><isset property="sdkroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.15.sdk" type="dir"/>
			</and>
		</condition>
		<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
			<and>
				<not><isset property="sdkroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk" type="dir"/>
			</and>
		</condition>

		<!-- If we're on 10.7 or lower, use gcc instead of clang -->
		<condition property="compiler" value="gcc-4.2">
			<and>
				<not><isset property="sdkroot"/></not>
				<available file="gcc-4.2" filepath="${env.PATH}"/>
			</and>
		</condition>
		<condition property="compiler" value="gcc">
			<and>
				<not><isset property="sdkroot"/></not>
				<not><available file="gcc-4.2" filepath="${env.PATH}"/></not>
				<available file="gcc" filepath="${env.PATH}"/>
			</and>
		</condition>

		<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
			<and>
				<not><isset property="sdkroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk" type="dir"/>
			</and>
		</condition>
		<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
			<and>
				<not><isset property="sdkroot"/></not>
				<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk" type="dir"/>
			</and>
		</condition>
		<condition property="sdkroot" value="${developer_path}/SDKs/MacOSx10.6.sdk"> <!-- Old XCode location -->
			<and>
				<not><isset property="sdkroot"/></not>
				<available file="${developer_path}/SDKs/MacOSx10.6.sdk" type="dir"/>
			</and>
		</condition>
	</target>

	<target name="clean">
		<delete failonerror="false">
			<fileset dir="i386"/>
			<fileset dir="x86_64"/>
			<fileset dir="." includes="liblwjgl.dylib"/>
			<fileset dir="." includes="lwjgl.symbols"/>
		</delete>
	</target>

	<target name="compile" depends="init">
		<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
			<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path} -I${native}/common -I${native}/common/opengl -I${native}/macosx"/>
			<!-- Map from *.m and *.c to .o -->
			<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
			<fileset dir="${native}/macosx" includes="*.m"/>
			<fileset dir="${native}/macosx" includes="*.c"/>
			<fileset dir="${native}/common" includes="*.c"/>
			<fileset dir="${native}/common/opengl" includes="*.c"/>
			<fileset dir="${native}/generated/openal" includes="*.c"/>
			<fileset dir="${native}/generated/opencl" includes="*.c"/>
			<fileset dir="${native}/generated/opengl" includes="*.c"/>
		</apply>
	</target>

	<target name="link" depends="init">
		<condition property="jdk_lib" value="${java.home}/lib">
			<available file="${java.home}/lib/libjawt.dylib" type="file"/>
		</condition>
		<condition property="jdk_lib" value="${java.home}/../Libraries">
			<not><isset property="jdk_lib"/></not>
		</condition>

		<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
			<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt"/>
			<fileset dir="${objdir}" includes="*.o"/>
		</apply>
		<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
			<arg line="-S -X"/>
			<fileset dir="." file="${libname}"/>
		</apply>
	</target>

	<target name="nativelibrary" depends="init">
		<echo message="        Compiler: ${compiler}"/>
		<echo message="      Mac OS SDK: ${sdkroot}"/>
		<echo message="JavaVM.framework: ${javavmroot}"/>

		<condition property="build_x86_64" value="1">
			<equals arg1="${compiler}" arg2="clang"/>
		</condition>

		<antcall target="-build"/>
	</target>

	<target name="-build" depends="-build_universal,-build_x86_x64"/>

	<target name="-build_universal" unless="build_x86_64">
		<mkdir dir="i386"/>

		<property name="universal_sdkroot" location="${sdkroot}"/>
		<property name="x86_64_sdkroot" location="${sdkroot}"/>
		<property name="universal_flags" value="-isysroot ${universal_sdkroot}"/>
		<antcall target="compile">
			<param name="dstdir" location="i386"/>
			<param name="sdkroot" location="${universal_sdkroot}"/>
			<param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/>
		</antcall>
		<antcall target="compile">
			<param name="dstdir" location="x86_64"/>
			<param name="sdkroot" location="${universal_sdkroot}"/>
			<param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch aarch64 -mmacosx-version-min=10.5"/>
		</antcall>
		<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
			<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
			<arg path="i386"/>
		</exec>
		<antcall target="link">
			<param name="objdir" location="i386"/>
			<param name="libname" value="liblwjgl-i386.dylib"/>
			<param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/>
		</antcall>
		<antcall target="link">
			<param name="objdir" location="x86_64"/>
			<param name="libname" value="liblwjgl-i86_64.dylib"/>
			<param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch aarch64 -mmacosx-version-min=10.5"/>
		</antcall>
		<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
			<arg value="-create"/>
			<srcfile/>
			<arg value="-output"/>
			<arg path="liblwjgl.dylib"/>
			<fileset file="i386/liblwjgl-i386.dylib"/>
			<fileset file="x86_64/liblwjgl-i86_64.dylib"/>
		</apply>
	</target>

	<target name="-build_x86_x64" if="build_x86_64">
		<antcall target="compile">
			<param name="dstdir" location="x86_64"/>
			<param name="sdkroot" location="${sdkroot}"/>
			<param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
		</antcall>
		<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
			<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
			<arg path="x86_64"/>
		</exec>
		<antcall target="link">
			<param name="objdir" location="x86_64"/>
			<param name="libname" value="liblwjgl-i86_64.dylib"/>
			<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
		</antcall>
		<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
			<arg value="-create"/>
			<srcfile/>
			<arg value="-output"/>
			<arg path="liblwjgl.dylib"/>
			<fileset file="x86_64/liblwjgl-i86_64.dylib"/>
		</apply>
	</target>
</project>

@r58Playz
Copy link

I managed to get LWJGL 2 to compile by tweaking the ant files and fixing a few errors in the macOS native code.

@FrankTCA
Copy link

FrankTCA commented Mar 7, 2021

@r58Playz Could you get in contact with me and tell me how you fixed it? I'm trying to do the same thing you are.

@r58Playz
Copy link

r58Playz commented Apr 5, 2021

Do you want the working libs or the source code?

Working libs: natives, classpath

PS: I did this all for modded MC on M1

@FrankTCA
Copy link

FrankTCA commented Apr 6, 2021

@r58Playz Both would be nice if you can.

@r58Playz
Copy link

r58Playz commented Apr 6, 2021

All in one repo with precompiled binaries: https://github.com/r58Playz/lwjgl2-m1

@huangguiniab huangguiniab changed the title how to compile libopenal.so for arm how to compile libopenal.so for arm (Linux) Jun 1, 2021
@huangguiniab
Copy link
Author

The title is misleading and I have edited it. At the same time, I also found a way. Now Minecraft 1.12 sounds can work normally on my Raspberry Pi. I will announce the method until the weekend.

@huangguiniab
Copy link
Author

huangguiniab commented Jun 2, 2021

In fact, the openal library of lwjgl 3 is compatible with lwjgl2. You only need to repackage the jar file and add the openal runtime library.

From these two links, you can find the pre-compiled libopenal.so.

arm32:https://build.lwjgl.org/stable/linux/arm32/libopenal.so

arm64:https://build.lwjgl.org/stable/linux/arm64/libopenal.so

The following is my packaged file, which contains openal.
pre-build-arm64-with-arm.zip

Unzip this file, rename it and put it in the designated place. After starting the game, you will find that your game has sound.

[Note:This No support Apple M1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants