0

I generated a static library from macos terminal with `ar rcs libws.a libws.o`
I have tested it with my own test program and everything works fine.
Now I would like to include the static library in android, but I have a build time error.
This is my cmake file
cmake_minimum_required(VERSION 3.10.2)
add_library(
        libws
        STATIC
        IMPORTED)

set_target_properties(libws
        PROPERTIES
        IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../jniLibs/libws/libws.a)

add_library(
        native-lib
        SHARED
        native-lib.cpp
        )

target_include_directories(native-lib PRIVATE
        ${CMAKE_SOURCE_DIR}/../jniLibs/libws/include
        logger )

#include_directories(src/main/cpp/)

find_library(
        log-lib
        log)

target_link_libraries(
        native-lib
        libws

        ${log-lib})

This is the build error

/src/main/cpp/../jniLibs/libws/libws.a -llog -latomic -lm -Bstatic -lc++ -Bdynamic -lm -lgcc -ldl -lc -lgcc -ldl /Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/23/crtend_so.o
/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: src/main/cpp/../jniLibs/libws/libws.a: no archive symbol table (run ranlib)

Any help?

Raffaele
  • 13
  • 5
  • Seems related: https://stackoverflow.com/questions/52397410/android-ndk-no-archive-symbol-table-run-ranlib – Michael May 09 '22 at 10:21
  • I saw, but it didn't help me. I have a static library built from command line with the architecture of my pc m1 (arm64). It is not compatible with Android, so I would have to generate an .a for each android architecture. How can I do? – Raffaele May 09 '22 at 15:09
  • 1
    _"I have a static library built from command line with the architecture of my pc"_ Don't do that. You need to build the library using the Android NDK. – Michael May 09 '22 at 15:13
  • how do i compile with ndk without importing files in android? I don't want to bring the folder to android because it is over 600mb – Raffaele May 09 '22 at 16:09
  • The [Android NDK](https://developer.android.com/ndk) is a set of tools that you run on your computer. – Michael May 09 '22 at 16:52

0 Answers0