This explain how to build JOGL 2.4 for Mac M1 with ARM64 processor and then extend the existing multiplatform release.
To allow keeping track of edits, Jogamp repository have been mirror here
- https://github.com/jzy3d/gluegen
- https://github.com/jzy3d/jcpp, should be check out as gluegen submodule, see Gluegen HowToBuild
- https://github.com/jzy3d/jogl
- https://github.com/jzy3d/jogl-utils
- https://github.com/jzy3d/jogl-demos (Existing copy)
- https://github.com/jzy3d/jogamp-scripting (Existing copy, see branch 2.4)
May be usefull
- https://github.com/jzy3d/jogl-demos-maven (not from Jogamp)
- https://jogamp.org/gluegen/doc/HowToBuild.html
- https://jogamp.org/jogl/doc/HowToBuild.html
- https://forum.jogamp.org/JOGL-for-Mac-ARM-Silicon-td4040887.html
- An ARM-aware JDK 8 is required to provide a rt.jar reference while building Gluegen and JOGL
- An ARM-aware JDK 11 is required to be able to read OpenJFX classes which are provided in JOGL dependencies.
Reminder : as stated in build doc, keep the same console for building Gluegen and then JOGL.
There was no problem to compile Gluegen but the generated .dylib file was for x86_64, not arm64. Therefore, I replaced
x86_64
byarm64
ingluegen/make/gluegen-cpptasks-base.xml
file in the two following lines:
<compilerarg value="x86_64" if="use.macosx64"/>
<linkerarg value="x86_64" if="use.macosx64"/>
Yielding to
<compilerarg value="arm64" if="use.macosx64"/>
<linkerarg value="arm64" if="use.macosx64"/>
and that was enough to get
libgluegen_rt.dylib
for arm64 architecture (info checked withlipo
command). I even succeed to create a "universal" .dylib file which combines both architectures with the command:lipo libgluegen_rt-arm64.dylib libgluegen_rt-x86_64.dylib -output libgluegen_rt.dylib -create
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/
ant -Dtarget.sourcelevel=1.8 -Dtarget.targetlevel=1.8 -Dtarget.rt.jar=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/rt.jar
- Generated jars are in build/
- Generated native libs in build/obj/
lipo ../../gluegen/build/obj/libgluegen_rt.dylib -archs
should output
arm64
cd ../build
jar xf gluegen-rt-natives-macosx-universal.jar natives/macosx-universal/
lipo natives/macosx-universal/libgluegen_rt.dylib -archs
ant -Dtarget.sourcelevel=1.8 -Dtarget.targetlevel=1.8 -Dtarget.rt.jar=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/rt.jar junit.run
Keep the same console open for building JOGL.
I get the SWT jar for MacOSX Aarch64 from my local maven repo and add it to the JOGL dependencies folder. I then edit build-common.xml
as follow
<!--<property name="swt-cocoa-macosx-x86_64.jar" value="${project.root}/make/lib/swt/cocoa-macosx-x86_64/swt.jar"/>
<condition property="swt.jar" value="${swt-cocoa-macosx-x86_64.jar}">
<and>
<istrue value="${isOSX}" />
<or>
<os arch="AMD64" />
<os arch="x86_64" />
</or>
</and>
</condition>-->
<property name="swt-cocoa-macosx-aarch64.jar" value="${project.root}/make/lib/swt/cocoa-macosx-aarch64/swt.jar"/>
<condition property="swt.jar" value="${swt-cocoa-macosx-aarch64.jar}">
<and>
<istrue value="${isOSX}" />
<!--<or>
<os arch="arm64" />
</or>-->
</and>
</condition>
cd ../../jogl/make
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/
ant -Dtarget.sourcelevel=1.8 -Dtarget.targetlevel=1.8 -Dtarget.rt.jar=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/rt.jar
Using JDK 8 to provide rt.jar but using JDK 11 to build is made on purpose!
ant -Dtarget.sourcelevel=1.8 -Dtarget.targetlevel=1.8 -Dtarget.rt.jar=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/rt.jar junit.run
- Clone jogamp-scripting next to jogl and gluegen.
- Unpack the existing 2.4 archive
mkdir jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64
mv jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib* jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64
Verify we bundled only x86_64 libs : running the below command should output x86_64
for each lib.
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libgluegen_rt.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libjogl_desktop.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libnativewindow_macosx.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libjogl_cg.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libnativewindow_awt.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libjogl_mobile.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-x86-64/libnewt_head.dylib -archs
mkdir jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/
cp jogl/build/lib/* jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/
cp gluegen/build/obj/libgluegen_rt.dylib jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/
Verify we bundled only arm64 libs : running the below command should output arm64
for each lib.
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libgluegen_rt.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libjogl_desktop.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libnativewindow_macosx.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libjogl_cg.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libnativewindow_awt.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libjogl_mobile.dylib -archs
lipo jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/lib-arm64/libnewt_head.dylib -archs
cd jogamp-scripting/input/jogamp-all-platforms/lib/macosx-universal/
mkdir natives
mkdir natives/macosx-universal
lipo lib-arm64/libgluegen_rt.dylib lib-x86-64/libgluegen_rt.dylib -output natives/macosx-universal/libgluegen_rt.dylib -create
lipo lib-arm64/libjogl_cg.dylib lib-x86-64/libjogl_cg.dylib -output natives/macosx-universal/libjogl_cg.dylib -create
lipo lib-arm64/libjogl_desktop.dylib lib-x86-64/libjogl_desktop.dylib -output natives/macosx-universal/libjogl_desktop.dylib -create
lipo lib-arm64/libjogl_mobile.dylib lib-x86-64/libjogl_mobile.dylib -output natives/macosx-universal/libjogl_mobile.dylib -create
lipo lib-arm64/libnativewindow_awt.dylib lib-x86-64/libnativewindow_awt.dylib -output natives/macosx-universal/libnativewindow_awt.dylib -create
lipo lib-arm64/libnativewindow_macosx.dylib lib-x86-64/libnativewindow_macosx.dylib -output natives/macosx-universal/libnativewindow_macosx.dylib -create
lipo lib-arm64/libnewt_head.dylib lib-x86-64/libnewt_head.dylib -output natives/macosx-universal/libnewt_head.dylib -create
Verify we bundled arm64+x86_64 libs : running the below command should output x86_64 arm64
for each lib.
lipo natives/macosx-universal/libjogl_cg.dylib -archs
lipo natives/macosx-universal/libjogl_desktop.dylib -archs
lipo natives/macosx-universal/libnativewindow_macosx.dylib -archs
lipo natives/macosx-universal/libjogl_cg.dylib -archs
lipo natives/macosx-universal/libnativewindow_awt.dylib -archs
lipo natives/macosx-universal/libjogl_mobile.dylib -archs
lipo natives/macosx-universal/libnewt_head.dylib -archs
mkdir jar.bak
cp -r jar/* jar.bak/
jar uf ../../jar/gluegen-rt-android-natives-macosx-universal.jar natives/macosx-universal/libgluegen_rt.dylib
jar uf ../../jar/gluegen-rt-natives-macosx-universal.jar natives/macosx-universal/libgluegen_rt.dylib
jar uf ../../jar/jogl-all-natives-macosx-universal.jar natives/macosx-universal/libjogl_desktop.dylib
jar uf ../../jar/jogl-all-natives-macosx-universal.jar natives/macosx-universal/libjogl_mobile.dylib
jar uf ../../jar/jogl-all-natives-macosx-universal.jar natives/macosx-universal/libnativewindow_macosx.dylib
jar uf ../../jar/jogl-all-natives-macosx-universal.jar natives/macosx-universal/libnativewindow_awt.dylib
jar uf ../../jar/jogl-all-natives-macosx-universal.jar natives/macosx-universal/libnewt_head.dylib
jar uf ../../jar/jogl-all-noawt-natives-macosx-universal.jar natives/macosx-universal/libjogl_mobile.dylib
jar uf ../../jar/jogl-all-noawt-natives-macosx-universal.jar natives/macosx-universal/libjogl_mobile.dylib
jar uf ../../jar/jogl-all-noawt-natives-macosx-universal.jar natives/macosx-universal/libnativewindow_awt.dylib
jar uf ../../jar/jogl-all-noawt-natives-macosx-universal.jar natives/macosx-universal/libnativewindow_macosx.dylib
jar uf ../../jar/jogl-all-noawt-natives-macosx-universal.jar natives/macosx-universal/libnewt_head.dylib
# left for later :
# jogl-all-android-natives-macosx-universal.jar
# jogl-all-mobile-natives-macosx-universal.jar
# joal-natives-macosx-universal.jar
# jocl-android-natives-macosx-universal.jar
# jocl-natives-macosx-universal.jar
# jogl-all-android-natives-macosx-universal.jar
# jogl-all-mobile-natives-macosx-universal.jar
Check jar where updated properly
ls -ahl ../../jar/ | grep macosx
Verify in a Maven project
https://github.com/jzy3d/jogamp-scripting/blob/2.4-to-jzy3d-maven-repo/maven/README.txt
- CLI fail while building
NativeTaglet.java
, either renamed toNativeTaglet_java
or rather use JDK 11 for building as indicated. CStructAnnotationProcessor.java:88: error: cannot find symbol @SupportedSourceVersion(SourceVersion.RELEASE_11)
. Either edit source to change to@SupportedSourceVersion(SourceVersion.RELEASE_8)
, or use JDK 11 for building as indicated.com.sun.javafx.tk.TKStage
: class file has wrong version 54.0, should be 52.0 > Was built with java 10, not 8 as required. Use JDK 10 or above to compile JOGL- Build hangs with
Unable to install ServerSocket: Address already in use (Bind failed)
: on Mac simplylsof | 59999
thenkill -9 PID
- Test do not finish because 7z is not a known file or directory :
brew install p7zip
- Exception stating
mach-o, but wrong architecture
: you are not running the JOGL program from an ARM-aware JDK/JRE. Using Azul Zulu may help - Log message stating
FALLBACK (log once): Fallback to SW vertex for line stipple
: thrown by Apple M1 OpenGL driver when you use a double in a fragment shader