java - How to link static library in jni? -


i have created header file "abc.h" declaration

int abc(); 

then, created .cpp file "abc.cpp" definition

int abc() {    return 0; } 

now created static library libabc.a above files.

i have created helloworld android project. created jni folder in subfolders "header" , "src" in it. in header folder have put abc.h , in src folder have put "abc.cpp". have created file "xyz.cpp" in jni folder wants use abc() function. when run ndk-build command error. jni/jnimagiccleanmanager.cpp:84: error: undefined reference function abc (something this)

how definition of abc() static library libabc.a have put libabc.a in same folder parallel android.mk. following android.mk file

local_path := $(call my-dir) include $(clear_vars) magic_clean_root := .. magic_clean_src_root := ../$(local_path)/src magic_clean_src_files := xyz.cpp magic_clean_c_includes := $(local_path)/headers/  local_static_libraries := magicclean local_module := myjnilib2   local_src_files := $(magic_clean_src_files) local_c_includes := $(magic_clean_c_includes) local_c_includes += . include $(build_shared_library) 

edit 1 : many asking why have abc.cpp when have static library, keeping code only. please tell how call function static library.

before use local_static_libraries need use prebuilt_static_library example, example uses gnu static lib, same yours.

include $(clear_vars)  local_module            := gnustl_static local_cppflags += -std=c++11 local_src_files         := ${ndk_root}/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/thumb/libgnustl_static.a local_export_c_includes := ${ndk_root}/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include local_export_c_includes += ${ndk_root}/sources/cxx-stl/gnu-libstdc++/4.9/include/  include $(prebuilt_static_library) 

you should put in android.mk


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -