Android开发教程:NDK编译静态库失败


LOCAL_SRC_FILES := \
src/dvn_cak.c \


LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/inc \


LOCAL_CFLAGS += -D__ANDROID__ -DTEST_IPANEL -DUSE_GRAPHICS_PIXEL_ALPHA -DHAVE_GFX_2D
include $(BUILD_STATIC_LIBRARY)
#include $(BUILD_SHARED_LIBRARY)

项目编译成动态库是正常的,将Android.mk里面的最后include $(BUILD_SHARED_LIBRARY)改成
include $(BUILD_STATIC_LIBRARY)编译静态库,运行NDK-BUILD却一点反应都没有,一闪而过。

从控制台中看:
Your group is currently "mkpasswd".  This indicates that
the /etc/passwd (and possibly /etc/group) files should be rebuilt.
See the man pages for mkpasswd and mkgroup then, for example, run
mkpasswd -l [-d] > /etc/passwd
mkgroup  -l [-d] > /etc/group
Note that the -d switch is necessary for domain users.
cygwin warning:
  MS-DOS style path detected: C:\NDK\android-ndk-r6b/ndk-build
  Preferred POSIX equivalent is: /cygdrive/c/NDK/android-ndk-r6b/ndk-build
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    #using-pathnames
根本就没有编译源文件,而编译动态库就会有:
Compile thumb  : dvnca <= dvn_cak.c
SharedLibrary  : libdvnca.so
Install        : libdvnca.so => libs/armeabi/libdvnca.so

解决办法有两种:
1、在Android.mk并行目录增加 Application.mk
文件内容:
APP_ABI := armeabi
APP_PLATFORM := android-9
APP_MODULES := libdvnca


2、在Android.mk中增加使用静态库的编译选项
include $(CLEAR_VARS)
LOCAL_MODULE    := libdvnca


LOCAL_SRC_FILES := \
src/dvn_cak.c \


LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/inc \


LOCAL_CFLAGS += -D__ANDROID__ -DTEST_IPANEL -DUSE_GRAPHICS_PIXEL_ALPHA -DHAVE_GFX_2D
include $(BUILD_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE    := test
LOCAL_STATIC_LIBRARIES := libdvnca
LOCAL_CFLAGS += -D__ANDROID__ -DTEST_IPANEL -DUSE_GRAPHICS_PIXEL_ALPHA -DHAVE_GFX_2D
include $(BUILD_SHARED_LIBRARY)

如此控制台输入的打印为:
StaticLibrary  : libdvnca.a
SharedLibrary  : libtest.so

Install        : libtest.so => libs/armeabi/libtest.so

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/pszzx.html