Build of tutorials fails for Android under MacOS
Hi, I am in the process of writing an app for Android and want to use GStreamer for an audio component.
I can build Android apps with C++ support in Android Studio using NDK. I also have successfully build "Playback tutorial 1" for MacOS from the Gstreamer tutorials ("Tutorial 1" is not functional in MacOS as mentioned here: https://stackoverflow.com/questions/35137165/gstreamer-1-0-video-from-tutorials-is-not-playing-on-macos).
Trying to build the tutorials for Android on MacOS using GStream 1.14.4 fails (in command line and Android Studio):
...
GStreamer : [GEN] => gst-build-arm64-v8a/gstreamer_android.c
GStreamer : [COMPILE] => gst-build-arm64-v8a/gstreamer_android.c
clang: error: argument unused during compilation: '--gcc-toolchain=/Users/johannes/Library/Android/sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64' [-Werror,-Wunused-command-line-argument]
make: *** [gst-build-arm64-v8a/gstreamer_android.o] Error
This can be fixed modifying the respective gstreamer-1.0.mk:
$(GSTREAMER_ANDROID_O): PRIV_CC_CMD := $(TARGET_CC) --sysroot=$(SYSROOT_GST_INC) $(SYSROOT_ARCH_INC_ARG) $(TARGET_CFLAGS) \ -c $(GSTREAMER_ANDROID_C) -Wall -Werror -o $(GSTREAMER_ANDROID_O) $(GSTREAMER_ANDROID_CFLAGS)
needs to be replaced with
(GSTREAMER_ANDROID_O): PRIV_CC_CMD := $(TARGET_CC) --sysroot=$(SYSROOT_GST_INC) $(SYSROOT_ARCH_INC_ARG) $(TARGET_CFLAGS) \ -c $(GSTREAMER_ANDROID_C) -Wall -o $(GSTREAMER_ANDROID_O) $(GSTREAMER_ANDROID_CFLAGS)
(removing -Werror).
Then another error occurs due to missing the Gold linker (not standard in MacOS):
...
GStreamer : [GEN] => gst-build-arm64-v8a/gstreamer_android.c
GStreamer : [COMPILE] => gst-build-arm64-v8a/gstreamer_android.c
GStreamer : [LINK] => gst-build-arm64-v8a/libgstreamer_android.so
clang: error: invalid linker name in argument '-fuse-ld=gold'
make: *** [buildsharedlibrary_arm64-v8a] Error 1
I tried the default ld linker to fix this:
GSTREAMER_LD := -fuse-ld=ld$(EXE_SUFFIX) -Wl,-soname,lib$(GSTREAMER_ANDROID_MODULE_NAME).so
instead of
GSTREAMER_LD := -fuse-ld=gold$(EXE_SUFFIX) -Wl,-soname,lib$(GSTREAMER_ANDROID_MODULE_NAME).so
Which leads to the following error:
...
GStreamer : [GEN] => gst-build-arm64-v8a/gstreamer_android.c GStreamer : [COMPILE] => gst-build-arm64-v8a/gstreamer_android.c GStreamer : [LINK] => gst-build-arm64-v8a/libgstreamer_android.so clang: warning: argument unused during compilation: '--gcc-toolchain=/Users/johannes/Library/Android/sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64' [-Wunused-command-line-argument]
ld: warning: directory not found for option '-L/home/nirbheek/projects/repositories/gst/cerbero.git/build/dist/android_universal/arm64/lib'
ld: warning: directory not found for option '-L/home/nirbheek/projects/repositories/gst/cerbero.git/build/android-ndk-16/platforms/android-21/arch-arm64/usr/lib'
ld: unknown option: --whole-archive
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [buildsharedlibrary_arm64-v8a] Error 1
I fiddled with the linker options for a while (e.g. replacing --whole-archive with -all_load) but ran into lots of new errors. What can I do here to advance?