1

Iam trying to compile my native code. Here is my android.mk file

//part1-static lib
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := irrlicht
IRRLICHT_LIB_NAME := lib$(LOCAL_MODULE).a

LOCAL_C_INCLUDES := include

LOCAL_SRC_FILES := \    
CColorConverter.cpp \
CCSMLoader.cpp \
CCubeSceneNode.cpp \
CD3D8Driver.cpp \
include $(BUILD_STATIC_LIBRARY)

//part-2 shared lib
include $(CLEAR_VARS)
LOCAL_MODULE := irrlichttest
LOCAL_SRC_FILES := test-app.cpp test.cpp android-receiver.cpp
LOCAL_C_INCLUDES := include
LOCAL_CFLAGS := -O3 -DANDROID_NDK -DDISABLE_IMPORTGL -I$(LOCAL_PATH)/../include/ -  I./include/
LOCAL_CPPFLAGS := -Wno-error=format-security
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lGLESv2
LOCAL_STATIC_LIBRARIES := irrlicht
include $(BUILD_SHARED_LIBRARY)

and here is my application.mk

APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-10
APP_MODULE := irrlicht irrlichttest

i want to compile "irrlicht" module first and then "irrlichttest' module. The problem iam facing is my irrlichttest module compile first and it start looking for reference and give me undefined reference error.Right now If i compile part1(static lib) only it successfully generate libirrlicht.a, But with part2 it start giving me error. What am i doing wrong.

Shaji Thorn Blue
  • 589
  • 2
  • 9
  • 19

2 Answers2

4

You have one extra \ at the end of your first LOCAL_SRC_FILES definition, this makes the 'include $(BUILD_STATIC_LIBRARY)' part go into LOCAL_SRC_FILES, and the line is never parsed / executed. In other words, due to this your module definition for the 'iirlicht' module is completely ignored by ndk-build, hence the problem you're seeing.

Remove the \ after CD3D8Driver.cpp, and that should fix it.

Digit
  • 2,073
  • 1
  • 13
  • 10
2

NDK will compile the irrlichttest sources, then irrlich sources, then create libirrlich.a, and only after that it will link libirrlichttest.so. It is very insightful to run

ndk-build clean all V=1

and see in the build log which commands are actually executed to build the project.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307