kfr icon indicating copy to clipboard operation
kfr copied to clipboard

Issue while linking(Android)

Open maciejmakowski2003 opened this issue 1 year ago • 3 comments

CMakeList.txt:

cmake_minimum_required(VERSION 3.12.0)
project(react-native-audio-api)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 20)

# Detect the operating system
if(APPLE)
    set(HAVE_ACCELERATE TRUE)
endif()

# Detect the processor and SIMD support
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
    set(HAVE_ARM_NEON_INTRINSICS TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
    set(HAVE_X86_SSE2 TRUE)
endif()

include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})

set(KFR_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/main/lib/cmake/kfr")

file(GLOB_RECURSE SOURCE_FILES
  "src/main/cpp/*.cpp"
  "src/main/cpp/*.h"
  "../common/cpp/*.cpp"
  "../common/cpp/*.h"
  "../common/cpp/core/*.cpp"
  "../common/cpp/core/*.h"
  "../common/cpp/wrappers/*.cpp"
  "../common/cpp/wrappers/*.h"
  "../common/cpp/HostObjects/*.cpp"
  "../common/cpp/HostObjects/*.h"
  "../common/cpp/utils/*.cpp"
  "../common/cpp/utils/*.h"
  "../common/cpp/types/*.h"
)

add_library(react-native-audio-api SHARED ${SOURCE_FILES})

file(GLOB DIRS CONFIGURE_DEPENDS "src/main/cpp/**" "../common/cpp/**")

target_include_directories(
  react-native-audio-api
  PRIVATE
  ${DIRS}
  "${REACT_NATIVE_DIR}/ReactCommon/jsi"
  "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/jni"
  "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/third-party/folly"
)

find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_package(oboe REQUIRED CONFIG)
find_package(KFR REQUIRED CONFIG)

set(LINK_LIBRARIES
  ReactAndroid::jsi
  fbjni::fbjni
  android
  log
  oboe::oboe
  KFR::kfr
  KFR::kfr_dsp
  KFR::kfr_dft
)

if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
  set(RN_VERSION_LINK_LIBRARIES
    ReactAndroid::reactnative
  )
else()
  set(RN_VERSION_LINK_LIBRARIES
    ReactAndroid::folly_runtime
    ReactAndroid::glog
    ReactAndroid::reactnativejni
  )
endif()

target_link_libraries(react-native-audio-api ${LINK_LIBRARIES} ${RN_VERSION_LINK_LIBRARIES})

Error:

> Task :prepareKotlinBuildScriptModel UP-TO-DATE
C/C++: CMake Error at CMakeLists.txt:56 (find_package):
C/C++:   Could not find a configuration file for package "KFR" that is compatible
C/C++:   with requested version "".
C/C++:   The following configuration files were considered but not accepted:
C/C++:     /Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/src/main/lib/cmake/kfr/KFRConfig.cmake, version: 6.1.0 (64bit)
[CXX1429] error when building with cmake using /Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/CMakeLists.txt: -- The C compiler identification is Clang 17.0.2
-- The CXX compiler identification is Clang 17.0.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/maciejmakowski/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/maciejmakowski/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring incomplete, errors occurred!
See also "/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/.cxx/Debug/u41w4e24/x86/CMakeFiles/CMakeOutput.log".

C++ build system [configure] failed while executing:
    /Users/maciejmakowski/Library/Android/sdk/cmake/3.22.1/bin/cmake \
      -H/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android \
      -DCMAKE_SYSTEM_NAME=Android \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
      -DCMAKE_SYSTEM_VERSION=24 \
      -DANDROID_PLATFORM=android-24 \
      -DANDROID_ABI=x86 \
      -DCMAKE_ANDROID_ARCH_ABI=x86 \
      -DANDROID_NDK=/Users/maciejmakowski/Library/Android/sdk/ndk/26.1.10909125 \
      -DCMAKE_ANDROID_NDK=/Users/maciejmakowski/Library/Android/sdk/ndk/26.1.10909125 \
      -DCMAKE_TOOLCHAIN_FILE=/Users/maciejmakowski/Library/Android/sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake \
      -DCMAKE_MAKE_PROGRAM=/Users/maciejmakowski/Library/Android/sdk/cmake/3.22.1/bin/ninja \
      "-DCMAKE_CXX_FLAGS=-O2 -frtti -fexceptions -Wall -fstack-protector-all" \
      -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/build/intermediates/cxx/Debug/u41w4e24/obj/x86 \
      -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/build/intermediates/cxx/Debug/u41w4e24/obj/x86 \
      -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_FIND_ROOT_PATH=/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/.cxx/Debug/u41w4e24/prefab/x86/prefab \
      -B/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android/.cxx/Debug/u41w4e24/x86 \
      -GNinja \
      -DANDROID_STL=c++_shared \
      -DREACT_NATIVE_DIR=/Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native
  from /Users/maciejmakowski/projects/react-native-audio-api/apps/fabric-example/node_modules/react-native-audio-api/android
CMake Error at CMakeLists.txt:56 (find_package):
  Could not find a configuration file for package "KFR" that is compatible
  with requested version "".

I have got binaries for all archs in ${CMAKE_CURRENT_SOURCE_DIR}/src/main/lib}

maciejmakowski2003 avatar Nov 22 '24 10:11 maciejmakowski2003

You're compiling for Android x86. There are no prebuilt x86 binaries for Android currently. Did you build the binaries yourself?

dancasarin avatar Nov 22 '24 21:11 dancasarin

Yes, I was compiling by myself. I guess I have built them. These are all binaries that I've built: Screenshot 2024-11-23 at 14 50 59

maciejmakowski2003 avatar Nov 23 '24 13:11 maciejmakowski2003

Maybe it makes sense to build only x86 (x86_64 have the same static libraries names and may overwrite them) and try again.

dancasarin avatar Nov 27 '24 08:11 dancasarin