I am badly pulling my hair as not able to figure out (even though searched a lot on google). Please help
Situation:
- I have a shared library. Let's say foo.so (Code completely in C++)
- Now in a new project, I want to use this shared library foo.so
- The new project code is also in C++. Let's say new project name is fooMate.
- I want to call the functions of functions or to use classes of foo in fooMate project cpp files without including the actual source code of foo project (i.e. by just using the foo.so file)
Question: How can we achieve this?
For Example:
class foo
{
const char* giveMeAString();
}
#include “foo.h”
const char* foo::giveMeAString()
{
return “Hello World!”;
}
Now I have compiled foo class successfully in shared library called: foo.so
Now suppose I am writing another project which is also having some CPP code. But this new CPP code wants to reuse the 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 I achieve this by using foo.so file instead of using actual source code of foo.cpp
Here is the Android.mk file that I am 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 and 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)