c++ - Android NDK: Multiple definition of .o and .c files -


i want implement library java , native code in app project in android studio. everytime when change c++ code, have recompile c++ files changes take effect in app. unfortunately ndk-build command not compile completely...

everytime run command, compiles c++ files , when tries create .so-files lots of errors looking (just others classes). changes simple , did not add c++ include headers etc.

/users/jenny/appproject/librarywithnativecode/src/main/obj/local/armeabi/objs/librarywithnativecode-mobile-example-app/src/worldpins/worldpinmessage.o: in function `_stlp_alloc_proxy': /users/jenny/ndk/android-ndk-r10e/sources/cxx-stl/stlport/stlport/stl/_string.c:647: multiple definition of `exampleapp::worldpins::worldpinmessage::focussedmodel() const' /users/jenny/appproject/librarywithnativecode/src/main/obj/local/armeabi/objs/librarywithnativecode-mobile-example-app/src/worldpins/worldpinmessage.o:/users/jenny/ndk/android-ndk-r10e/sources/cxx-stl/stlport/stlport/stl/_string.c:647: first defined here 

my android.mk , application.mk looks following

android.mk

local_path := $(call my-dir)  $(info target_arch_abi $(target_arch_abi))  $(info local_path $(local_path))  prebuilt_libs := $(local_path)/../libs/librarywithnativecode/prebuilt/android-$(target_arch_abi)  include $(clear_vars) local_module := librarywithnativecode-sdk-lib local_src_files := $(prebuilt_libs)/librarywithnativecode-sdk.a include $(prebuilt_static_library)  include $(clear_vars) local_module := png-lib local_src_files := $(prebuilt_libs)/libpng.a local_export_c_includes := $(local_path)/../libs/librarywithnativecode/png include $(prebuilt_static_library)  include $(clear_vars) local_module := curl-lib local_src_files := $(prebuilt_libs)/libcurl.a local_export_c_includes := $(local_path)/../libs/librarywithnativecode/curl/android-$(target_arch_abi) include $(prebuilt_static_library)  include $(clear_vars) local_module := ssl-lib local_src_files := $(prebuilt_libs)/libssl.a include $(prebuilt_static_library)  include $(clear_vars) local_module := crypto-lib local_src_files := $(prebuilt_libs)/libcrypto.a include $(prebuilt_static_library)  include $(clear_vars) local_module := http-parser-lib local_src_files := $(prebuilt_libs)/libhttp-parser.a local_export_c_includes := $(local_path)/../libs/librarywithnativecode/http-parser include $(prebuilt_static_library)  include $(clear_vars) local_module := jpeg-lib local_src_files := $(prebuilt_libs)/libjpeg.a include $(prebuilt_static_library)  include $(clear_vars) local_module := turbojpeg-lib local_src_files := $(prebuilt_libs)/libturbojpeg.a local_export_c_includes := $(local_path)/../libs/librarywithnativecode/jpeg-turbo include $(prebuilt_static_library)  include $(clear_vars)  local_module := librarywithnativecode-mobile-example-app local_ldlibs := -llog -landroid -legl -lglesv2 -lz -lm local_ldlibs += -fuse-ld=bfd local_static_libraries := librarywithnativecode-sdk-lib png-lib curl-lib ssl-lib crypto-lib http-parser-lib jpeg-lib turbojpeg-lib android_native_app_glue ndk_helper  local_cflags += -wall -wno-unknown-pragmas -wno-sign-compare -wno-format-security -wno-reorder #local_cflags += -werror  ifdef compile_cpp_11   $(info configured c++11)   local_cppflags += -dcompile_cpp_11=1 -std=c++11 else   $(info configured c++0x) endif  os_name:=$(shell uname -s)  get_android_cpp_files_cmd := find $(local_path) -type f  -iname "*.cpp" get_android_includes_cmd  := find $(local_path) -type d get_shared_cpp_files_cmd  := find $(local_path)/src -type f  -iname "*.cpp" get_shared_includes_cmd   := find $(local_path)/src -type d get_platform_includes_cmd := find $(local_path)/../libs/librarywithnativecode/platform -type d ! -path "*/osx/*" ! -path "*/ios/*"   ifeq ($(os_name),darwin)     cppfiles := ${shell ${get_android_cpp_files_cmd}}     cppfiles += ${shell ${get_shared_cpp_files_cmd}}      includes := ${shell ${get_android_includes_cmd}}     includes += ${shell ${get_shared_includes_cmd}}     includes += ${shell ${get_platform_includes_cmd}} else     # assume windows if not specified (due no uname)     cppfiles := ${shell sh -c '${get_android_cpp_files_cmd}'}     cppfiles += ${shell sh -c '${get_shared_cpp_files_cmd}'}      includes := ${shell sh -c '${get_android_includes_cmd}'}     includes += ${shell sh -c '${get_shared_includes_cmd}'}     includes += ${shell sh -c '${get_platform_includes_cmd}'} endif   local_src_files := $(cppfiles:$(local_path)/%=%) local_c_includes := $(includes)  local_c_includes += $(local_path)/../libs/librarywithnativecode/rapidjson local_c_includes += $(local_path)/../libs/librarywithnativecode/rapidjson/internal  include $(build_shared_library)  $(call import-module,android/native_app_glue) $(call import-module,android/ndk_helper) 

application.mk

app_platform := android-12 app_stl := stlport_shared app_abi := armeabi,armeabi-v7a,arm64-v8a 

anyone has idea how fix this?

i think root cause of problem you're including same files more once compilation since get_android_cpp_files_cmd (find $(local_path) -type f -iname "*.cpp") returning files returned get_shared_cpp_files_cmd (find $(local_path)/src -type f -iname "*.cpp") find recursive.

also, unrelated issue, wonder why you're compiling armeabi, armeabi-v7a, arm64-v8a, , targeting android-12+ ? honeycomb_mr1 quite confidential version, why not directly targeting kitkat+ instead, , including x86 arch in list?


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -