kcat / openal-soft

OpenAL Soft is a software implementation of the OpenAL 3D audio API.
Other
2.23k stars 536 forks source link

CMake Android configuration on OSX fails #372

Open hsdk123 opened 4 years ago

hsdk123 commented 4 years ago

Hi, I'm using the ndk toolchain here: https://developer.android.com/ndk/guides/cmake. I get the following cmake configuration errors when trying to cmake config for Android on osx:

WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/AudioToolbox.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/ApplicationServices.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/AudioUnit.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/CoreAudio.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/AudioToolbox.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/ApplicationServices.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/AudioUnit.framework".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "OpenAL" requests linking to directory "/System/Library/Frameworks/CoreAudio.framework".  Targets may link only to libraries.  CMake is dropping the item

It seems that OpenAL is trying to pull in the osx backends instead of doing something particular for Android.

kcat commented 4 years ago

What you provided are only warnings, which usually don't stop the build. Can you provide the full output? You can set the ALSOFT_BACKEND_COREAUDIO cmake option to FALSE to disable the CoreAudio backend which links to those OSX frameworks. Though it's odd that FIND_LIBRARY() succeeds in finding the frameworks if it can't use them.

hsdk123 commented 4 years ago

It seems to be trying to link in CoreAudio:

/Users/hkim809/Desktop/SoulEngineProject/Light.vn-multi/extlibs/openal-soft/alc/backends/coreaudio.cpp:37:10: fatal error:
      'AudioUnit/AudioUnit.h' file not found
#include <AudioUnit/AudioUnit.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [openal-soft/CMakeFiles/OpenAL.dir/alc/backends/coreaudio.cpp.o] Error 1

(this is the error on build)

hsdk123 commented 4 years ago

I've also tried setting the CoreAudio option off as you've mentioned, but in this case I still see other errors:

C02Z38WNLVDQ:build-android hkim809$ make
[  3%] Built target CorradeUtilityObjects
[  5%] Built target CorradeUtility
[  6%] Built target CorradeInterconnect
[  7%] Built target CorradePluginManagerObjects
[  7%] Built target CorradePluginManager
[  8%] Built target CorradeTestSuite
[  9%] Built target native-tools
[  9%] Built target build_version
[ 11%] Built target common
[ 24%] Built target OpenAL
[ 25%] Built target ex-common
[ 25%] Linking C executable ../../bin/alrecord
/Users/hkim809/Desktop/DevTools/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libOpenSLES.so, needed by ../../bin/libopenal.so, not found (try using -rpath or -rpath-link)
/Users/hkim809/Desktop/DevTools/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: liblog.so, needed by ../../bin/libopenal.so, not found (try using -rpath or -rpath-link)
../../bin/libopenal.so: undefined reference to `slCreateEngine'
../../bin/libopenal.so: undefined reference to `__android_log_print'
../../bin/libopenal.so: undefined reference to `SL_IID_PLAY'
../../bin/libopenal.so: undefined reference to `SL_IID_ANDROIDCONFIGURATION'
../../bin/libopenal.so: undefined reference to `SL_IID_RECORD'
../../bin/libopenal.so: undefined reference to `SL_IID_ENGINE'
../../bin/libopenal.so: undefined reference to `SL_IID_ANDROIDSIMPLEBUFFERQUEUE'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../bin/alrecord] Error 1
make[1]: *** [openal-soft/CMakeFiles/alrecord.dir/all] Error 2
make: *** [all] Error 2
kcat commented 4 years ago
... libOpenSLES.so, needed by ../../bin/libopenal.so, not found ...
... liblog.so, needed by ../../bin/libopenal.so, not found ...

That's odd. It finds them during cmake and successfully links libopenal.so with them, but then fails to find them when linking libopenal.so to a program. Not sure why that would happen, since I'm not doing anything abnormal with CMake to find and use those libraries.

fbirot commented 4 years ago

Compilation for android worked for me correctly on OSX.

In order to compile it, I've specified the toolchain directly in the command: cmake . -DCMAKE_TOOLCHAIN_FILE=/Users/fbirot/Library/Android/sdk/ndk/21.1.6352462/build/cmake/android.toolchain.cmake

I've also set ALSOFT_UTILS, ALSOFT_EXAMPLES and ALSOFT_INSTALL options to OFF. I have then generated a java wrapper using SWIG and included the generated wrapper file like this target_sources(OpenAL PRIVATE "${OpenAL_SOURCE_DIR}/android/jni/OpenALSoft_wrap.c")

Android studio can also directly work with cmake, which can be more handy than using cmake from the command line.

iscle commented 4 years ago
... libOpenSLES.so, needed by ../../bin/libopenal.so, not found ...
... liblog.so, needed by ../../bin/libopenal.so, not found ...

That's odd. It finds them during cmake and successfully links libopenal.so with them, but then fails to find them when linking libopenal.so to a program. Not sure why that would happen, since I'm not doing anything abnormal with CMake to find and use those libraries.

This error also happened to me when building with: cmake .. -DANDROID_PLATFORM=21 -DANDROID_ABI=arm84_v8a -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake on a clean Ubuntu 18.04 LTS install.

iscle commented 4 years ago

Did you ever find a fix for this issue? It's really weird, as the .so files are present!