protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

use protobuf_full.a library for android ndk problem

Open iron-man-forever opened this issue 8 years ago • 1 comments

the protobuf_full.a from chromium project build for android (target_os="android" target_cpu=arm) CMakeLists.txt add protobuf configure include_directories(libs/protobuf/src)

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

         # Sets the library as a shared library.
         SHARED
         src/main/cpp/proto/superman_permission.pb.cc
         # Provides a relative path to your source file(s).
         src/main/cpp/native-lib.cpp )

Searches for a specified prebuilt library and stores the path as a

variable. Because CMake includes system libraries in the search path by

default, you only need to specify the name of the public NDK library

you want to add. CMake verifies that the library exists before

completing its build.

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 )

Specifies libraries CMake should link to your target library. You

can link multiple libraries, such as libraries you define in this

build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library. native-lib # protobuf ${CMAKE_SOURCE_DIR}/libs/protobuf/libs/${ANDROID_ABI}/libprotobuf_full.a # Links the target library to the log library # included in the NDK. ${log-lib} )

but the ndk compiler will post error like this /home/daniel/Applications/Google/Android/SDK/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open ../../../../libs/protobuf/libs/armeabi-v7a/protobuf_full/arena.o: No such file or directory /home/daniel/Applications/Google/Android/SDK/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open ../../../../libs/protobuf/libs/armeabi-v7a/protobuf_full/arenastring.o: No such file or directory /home/daniel/Applications/Google/Android/SDK/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open ../../../../libs/protobuf/libs/armeabi-v7a/protobuf_full/generated_message_util.o: No such file or directory /home/daniel/Applications/Google/Android/SDK/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open ../../../../libs/protobuf/libs/armeabi-v7a/protobuf_full/coded_stream.o: No such file or directory

iron-man-forever avatar Jun 23 '18 04:06 iron-man-forever

@CaiHuan The issue content is not readable. Can you format it and repost? Also it seems you are not using the code from our repository at all.

xfxyjwf avatar Jun 23 '18 06:06 xfxyjwf