Hi. my name is take.de.x
I maked my C++ library, libtest.a, iimplemented global function
I was going to link this library to Esenthel Application
Then it became such an error.
----------------------------------------
D:/(ndk directory)/toolchains/x86-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: ./obj/local/x86/objs-debug/Project/Main.o: in function Init():jni/../../Source/main.cpp:21: error: undefined reference to 'GlobalFunction(void*, unsigned int*)'
D:/(ndk directory)/toolchains/x86-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: ./obj/local/x86/objs-debug/Project/Main.o: in function Init():jni/../../Source/main.cpp:23: error: undefined reference to 'inc::misc::NamedFunction(void*, int, unsigned int)'
----------------------------------------
I seem to succeed in a link in armeabi.
please help me.
-------------------------------------
OS:Windows7
----- global_function.h ---------------
#ifndef _TEST_MISC_GLOBAL_FUNCTIONS_H_
#define _TEST_MISC_GLOBAL_FUNCTIONS_H_
void GlobalFunction(void* ptr, size_t* size);
namespace inc {
namespace misc {
void NamedFunction(void*ptr, int count, size_t size);
}
}
#endif // _TEST_MISC_GLOBAL_FUNCTIONS_H_
----- global_function.cpp ---------------
#include <test/misc/global_functions.h>
void GlobalFunction(void* ptr, size_t* size)
{
int a = 0;
++a;
}
namespace inc {
namespace misc {
void NamedFunction(void* ptr, int count, size_t size)
{
int a = 0;
++a;
}
}
}
----- Android.mk ---------------
LOCAL_PATH := $(call my-dir)
MY_INCLUDES := $(LOCAL_PATH)/../../include \
$(LOCAL_PATH)/../src
# test
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_CFLAGS := -ffast-math -fsigned-char -O2 -fPIC -DPIC \
-DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_
TARGET_ARCH_ABI := armeabi armeabi-v7a x86
LOCAL_C_INCLUDES := $(MY_INCLUDES)
CPP_FILES := $(shell find $(LOCAL_PATH)/../src -name '*.cpp' | grep -v precompile)
C_FILES := $(shell find $(LOCAL_PATH)/../src -name '*.c' | grep -v precompile)
LOCAL_SRC_FILES := $(CPP_FILES)
LOCAL_SRC_FILES += $(C_FILES)
include $(BUILD_STATIC_LIBRARY)
----- Android.mk(Esenthel Application) ---------------
LOCAL_PATH := $(call my-dir)
# EsenthelEngine
include $(CLEAR_VARS)
LOCAL_MODULE := EsenthelEngine
LOCAL_SRC_FILES := (Essenthel Directory)/Bin/Android/EsenthelEngine-$(TARGET_ARCH_ABI).a
include $(PREBUILT_STATIC_LIBRARY)
# libtest
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := D:/(My library Directory)/obj/local/armeabi/libtest.a
include $(PREBUILT_STATIC_LIBRARY)
# Project
include $(CLEAR_VARS)
LOCAL_MODULE := Project
LOCAL_SRC_FILES := Main.cpp
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lz -lOpenSLES
LOCAL_STATIC_LIBRARIES := EsenthelEngine android_native_app_glue cpufeatures libtest
LOCAL_CFLAGS := -I.. -ID:/(My library Directory)/include -fshort-wchar -ffast-math -Wl,--no-wchar-size-warning -fpermissive
LOCAL_CPPFLAGS := -I.. -ID:/(My library Directory)/include -fshort-wchar -ffast-math -Wl,--no-wchar-size-warning -fpermissive -ffriend-injection -Wno-invalid-offsetof -std=c++11
LOCAL_CPP_FEATURES := rtti exceptions
include $(BUILD_SHARED_LIBRARY)
$(call import-module, android/native_app_glue)
$(call import-module, android/cpufeatures)
---------------------------------------------------------------------------