Friday, January 10, 2014

android-cmake windows

android-cmake is a great solution to build existing libraries, e.g. libpng, for android. In my linux, it works flawlessly. I compiled assimp, libpng, libz, and bullet so far. And then, I can add them to my project in the android.mk, which I attached it to the end.

android-cmake works out-of-box in Linux. In window, there is no softlink, make install will fail. I just copy those target files, such as *.so, *.a, and bin files, to the build folder, and then make install works.

"Could not find any working toolchain in the NDK. Probably your Android NDK is broken" drove me to nut. I got this problem on one PC, but another one works perfectly. I finally found out, android-cmake works only with cmake 2.8.12.2. I updated the old one. Everything works now.

In order to link your prebuilt libs, you have to define your own LOCAL_MODULE and put them in the LOCAL_STATIC_LIBRARIES list



android.mk

LOCAL_PATH := $(call my-dir)

#assimp
include $(CLEAR_VARS)
LOCAL_MODULE := assimp
LOCAL_SRC_FILES := $(ANDROID_TOOLCHAIN)/lib/libassimp.a
LOCAL_EXPORT_C_INCLUDES := $(ANDROID_TOOLCHAIN)/include/assimp
include $(PREBUILT_STATIC_LIBRARY)

#libpng
include $(CLEAR_VARS)
LOCAL_MODULE := libpng
LOCAL_SRC_FILES := $(ANDROID_TOOLCHAIN)/lib/libpng.a
LOCAL_EXPORT_C_INCLUDES := $(ANDROID_TOOLCHAIN)/include/
include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := game
LOCAL_C_INCLUDES += $(ANDROID_TOOLCHAIN)/include/eigen3/
LOCAL_SRC_FILES := ../../common/game.cpp jni.cpp assets_file_io.cpp
LOCAL_STATIC_LIBRARIES := assimp libpng
LOCAL_LDLIBS := -lz -lstdc++ -llog -lGLESv2 -lEGL -landroid
include $(BUILD_SHARED_LIBRARY)

No comments:

Post a Comment