android ndk - Need NDK Help: How to call a C++ function for shared library from another project that uses C++ -
i badly pulling hair not able figure out (even though searched lot on google). please help
situation:
- i have shared library. let's foo.so (code in c++)
- now in new project, want use shared library foo.so
- the new project code in c++. let's new project name foomate.
- i want call functions of functions or use classes of foo in foomate project cpp files without including actual source code of foo project (i.e. using foo.so file)
question: how can achieve this?
for example:
class foo { const char* givemeastring(); } #include “foo.h” const char* foo::givemeastring() { return “hello world!”; }
now have compiled foo class in shared library called: foo.so
now suppose writing project having cpp code. new cpp code wants reuse static library.
// declaration
class foomate { void printdemo(); }
// implementation
#include “foomate.h” #include “foo.h” void foomate::printdemo() { foo *testfoo = new foo(); cout<<givemeastring(); }
how can achieve using foo.so file instead of using actual source code of foo.cpp
here android.mk file using
#adding foo.so file in project. local_path := $(call my-dir) include $(clear_vars) local_module := foo-lib-module local_src_files := foo-lib.so local_export_c_includes := include include $(prebuilt_shared_library) #new project , source code include $(clear_vars) local_module := foomate-module local_module_filename := foomate-lib local_src_files := foomate.cpp local_c_includes := $(local_path)/classes/include include $(build_shared_library)
Comments
Post a Comment