0

I'm trying to build my Android app with custom native c++ code and OpenCV 3.4.16. I need to stay on 3.4.x for now since I'm using some deprecated modules that are gone in 4.x

The build and app work fine on all ABIs except arm64-v8a and unfortunately, I've been banging my head off a wall for the last couple of weeks to try to make this work with no avail.

I already tried everything here: "local symbol '__bss_start' in global part of symbol table" only in Android NDK aarch64 build

...and most of the other similar issues on SO have been answered for a long time.

Here are some relevant parts of my gradle.build:

android {
    buildToolsVersion buildToolsVersion
// tried all these NDK versions
//    ndkVersion = "25.2.9519653"
//    ndkVersion = "21.4.7075529"
//    ndkVersion = "23.1.7779620"
    ndkVersion = "22.1.7171670"
//    ndkVersion = "16.1.4479499"

...

    defaultConfig {
        ...
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions -fuse-ld=lld"
                abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
            }
        }
        ...
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
            version '3.18.1+'
        }
    }
...

Here's my CMakeLists.txt based on the OpenCV setup instructions:

cmake_minimum_required(VERSION 3.4.1)
set (CMAKE_CXX_STANDARD 11)

# OpenCV stuff
include_directories(../../../OpenCV-android-sdk/sdk/native/jni/include)
add_library( lib_opencv SHARED IMPORTED )
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)

add_library( # Sets the name of the library.
             native-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             # Associated headers in the same location as their source
             # file are automatically included.
             src/main/cpp/native-lib.cpp
             src/main/cpp/MyCustomModule.cpp)

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

target_link_libraries( # Specifies the target library.
                       native-lib

                       # OpenCV lib
                       lib_opencv

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )

The error I'm getting (only on arm64 builds):

C/C++: ld.lld: error: found local symbol '__bss_start' in global part of symbol table in file /Users/myUser/AndroidApp/android/app/src/main/jniLibs/arm64-v8a/libopencv_java3.so

OpenCV releases come with the arm64-v8a library already built, but it seems that the symbol table is not configured properly based on the error I'm seeing. I tried to find more information about this in their community but I reach a dead-end all the time.

Has anyone experienced a similar problem and managed to fix the issue?


Some info about my environment:

  • MacOS 13.1
  • Android Studio - Electric Eel Patch 2
  • Cmake 3.22.1
  • Tried NDK 21, 22, 23, 25, 16(my app doesn't support this)
Raz
  • 1,601
  • 2
  • 15
  • 23

0 Answers0