'Compile with CMAKE and invalid sh_info in symbol table

sorry bad english

cloned and compiled this project in Android Studio: https://github.com/Pangu-Immortal/KeepAlivePerfect/

During compile, got the following error (using ndk 24.0.8215888):

KeepAlivePerfect/library/src/main/cpp/binder_libs/armeabi-v7a/libbinder.so: invalid sh_info in symbol table

tested both in linux and windows. Same error.

plz help



Solution 1:[1]

Finally could compile with changing SHARED to STATIC in CMakeLists.txt. And some more config.

Here are the changes:

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/)

add_compile_options(-fno-rtti -O3 -v)

message(@@@${CMAKE_CURRENT_SOURCE_DIR})

link_directories(binder_libs/${CMAKE_ANDROID_ARCH_ABI})

aux_source_directory(. SRC_LIST) # ??????????.cpp??

add_library( # Sets the name of the library.
        keep_alive

        # Sets the library as a shared library.
        STATIC # Changed from SHARED to STATIC

        # ???????????
        ${SRC_LIST} main.cpp art.cpp)

# More Config
set_target_properties(keep_alive PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/binder_libs/${ANDROID_ABI}/libutils.so)
set_target_properties(keep_alive PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/binder_libs/${ANDROID_ABI}/libc.so)
set_target_properties(keep_alive PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/binder_libs/${ANDROID_ABI}/libcutils.so)
set_target_properties(keep_alive PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/binder_libs/${ANDROID_ABI}/libutils.so)
# The END

find_library(log-lib log)

target_link_libraries(
        keep_alive
        ${log-lib}
)

More information in an issue in main project: https://github.com/Pangu-Immortal/KeepAlivePerfect/issues/8#issuecomment-1107427875

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1