歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

Android開發教程:NDK編譯靜態庫失敗

Android---NDK編譯靜態庫失敗

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 $(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:
    http://cygwin.com/cygwin-ug-net/using.html#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

Copyright © Linux教程網 All Rights Reserved