Dear Android developers
I want to add some feature into the libselinux using libutils
- libselinux: external/libselinux
- libutils: system/core/libutils
The libselinux build succeeded, but the init(system/core/init) build failed.
----------------------------------------------------------------------------------------
target StaticExecutable: init (my_project/target/product/my_project/obj/EXECUTABLES/init_intermediates/LINKED/init)
my_project/target/product/my_project/obj/STATIC_LIBRARIES/libselinux_intermediates/libselinux.a(dump_stack.o): In function `dump_stack_android':
my_source/android/external/libselinux/src/dump_stack.cpp:5: undefined reference to `android::CallStack::CallStack()'
my_source/android/external/libselinux/src/dump_stack.cpp:6: undefined reference to `android::CallStack::update(int, int)'
my_source/android/external/libselinux/src/dump_stack.cpp:6: undefined reference to `android::CallStack::~CallStack()'
collect2: error: ld returned 1 exit status
make: *** [my_project/target/product/my_project/obj/EXECUTABLES/init_intermediates/LINKED/init] Error 1
make: Leaving directory `my_project/android'
#### make failed to build some targets (19 seconds) ####
----------------------------------------------------------------------------------------
I modified my source like it.
----------------------------------------------------------------------------------------
external/libselinux/Android.mk [modified source]
LOCAL_SRC_FILES := $(common_SRC_FILES) $(common_HOST_FILES) src/android.c
+LOCAL_SRC_FILES := $(common_SRC_FILES) $(common_HOST_FILES) src/android.c src/dump_stack.cpp
LOCAL_MODULE:= libselinux
LOCAL_MODULE_TAGS := eng
-LOCAL_STATIC_LIBRARIES := libmincrypt
+LOCAL_STATIC_LIBRARIES := libmincrypt libutils
external/libselinux/src/dump_stack.cpp [new_file]
+#include <utils/CallStack.h>
+using namespace android;
+extern "C" void dump_stack_android(void)
+{
+ CallStack stack;
+ stack.update();
+// stack.dump();
+ }
----------------------------------------------------------------------------------------
Please help me to solve this build error.
Thank you
Best regards