mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-30 18:59:18 -05:00
Introduced a separate linking step in the build script to prevent Relocations in generic ELF (EM: 183) issue with arm64 compilation.
@ -136,14 +136,12 @@ Okay, finally we can build our APK file. You can create a shell script to build
|
|||||||
#
|
#
|
||||||
# Compile raylib project for Android
|
# Compile raylib project for Android
|
||||||
# ______________________________________________________________________________
|
# ______________________________________________________________________________
|
||||||
#
|
|
||||||
# NOTE: If you excluded any ABIs in the previous steps, remove them from this list too
|
|
||||||
|
|
||||||
# TODO: arm64-v8a building doesn't work, ARM64 devices can still run the 32 bit version:
|
# stop on error and display each command as it gets executed. Optional step but helpful in catching where errors happen if they do.
|
||||||
# /usr/bin/ld: /tmp/main-08f12a.o: Relocations in generic ELF (EM: 183)
|
set -xe
|
||||||
# /usr/bin/ld: /tmp/main-08f12a.o: Relocations in generic ELF (EM: 183)
|
|
||||||
# /usr/bin/ld: /tmp/main-08f12a.o: error adding symbols: file in wrong format
|
# NOTE: If you excluded any ABIs in the previous steps, remove them from this list too
|
||||||
ABIS="armeabi-v7a x86 x86_64"
|
ABIS="arm64-v8a armeabi-v7a x86 x86_64"
|
||||||
|
|
||||||
BUILD_TOOLS=android/sdk/build-tools/29.0.3
|
BUILD_TOOLS=android/sdk/build-tools/29.0.3
|
||||||
TOOLCHAIN=android/ndk/toolchains/llvm/prebuilt/linux-x86_64
|
TOOLCHAIN=android/ndk/toolchains/llvm/prebuilt/linux-x86_64
|
||||||
@ -173,21 +171,29 @@ for ABI in $ABIS; do
|
|||||||
case "$ABI" in
|
case "$ABI" in
|
||||||
"armeabi-v7a")
|
"armeabi-v7a")
|
||||||
CCTYPE="armv7a-linux-androideabi"
|
CCTYPE="armv7a-linux-androideabi"
|
||||||
|
ARCH="arm"
|
||||||
|
LIBPATH="arm-linux-androideabi"
|
||||||
ABI_FLAGS="-std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
|
ABI_FLAGS="-std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"arm64-v8a")
|
"arm64-v8a")
|
||||||
CCTYPE="aarch64-linux-android"
|
CCTYPE="aarch64-linux-android"
|
||||||
|
ARCH="aarch64"
|
||||||
|
LIBPATH="aarch64-linux-android"
|
||||||
ABI_FLAGS="-std=c99 -target aarch64 -mfix-cortex-a53-835769"
|
ABI_FLAGS="-std=c99 -target aarch64 -mfix-cortex-a53-835769"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"x86")
|
"x86")
|
||||||
CCTYPE="i686-linux-android"
|
CCTYPE="i686-linux-android"
|
||||||
|
ARCH="i386"
|
||||||
|
LIBPATH="i686-linux-android"
|
||||||
ABI_FLAGS=""
|
ABI_FLAGS=""
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"x86_64")
|
"x86_64")
|
||||||
CCTYPE="x86_64-linux-android"
|
CCTYPE="x86_64-linux-android"
|
||||||
|
ARCH="x86_64"
|
||||||
|
LIBPATH="x86_64-linux-android"
|
||||||
ABI_FLAGS=""
|
ABI_FLAGS=""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -202,11 +208,18 @@ for ABI in $ABIS; do
|
|||||||
$TOOLCHAIN/bin/llvm-ar rcs lib/$ABI/libnative_app_glue.a $NATIVE_APP_GLUE/native_app_glue.o
|
$TOOLCHAIN/bin/llvm-ar rcs lib/$ABI/libnative_app_glue.a $NATIVE_APP_GLUE/native_app_glue.o
|
||||||
|
|
||||||
# Compile project
|
# Compile project
|
||||||
$CC src/*.c -o android/build/lib/$ABI/libmain.so -shared \
|
for file in src/*.c; do
|
||||||
$INCLUDES -I$TOOLCHAIN/sysroot/usr/include/$CCTYPE $FLAGS $ABI_FLAGS \
|
$CC -c $file -o "$file".o \
|
||||||
-Wl,-soname,libmain.so -Wl,--exclude-libs,libatomic.a -Wl,--build-id \
|
$INCLUDES -I$TOOLCHAIN/sysroot/usr/include/$CCTYPE $FLAGS $ABI_FLAGS
|
||||||
-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \
|
done
|
||||||
-Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate \
|
|
||||||
|
# Link the project with toolchain specific linker to avoid relocations issue.
|
||||||
|
$TOOLCHAIN/bin/ld.lld src/*.o -o android/build/lib/$ABI/libmain.so -shared \
|
||||||
|
--exclude-libs libatomic.a --build-id \
|
||||||
|
-z noexecstack -z relro -z now \
|
||||||
|
--warn-shared-textrel --fatal-warnings -u ANativeActivity_onCreate \
|
||||||
|
-L$TOOLCHAIN/sysroot/usr/lib/$LIBPATH/29 \
|
||||||
|
-L$TOOLCHAIN/lib/clang/17/lib/linux/$ARCH \
|
||||||
-L. -Landroid/build/obj -Llib/$ABI \
|
-L. -Landroid/build/obj -Llib/$ABI \
|
||||||
-lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
|
-lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user