当前位置:首页 > 芯闻号 > 充电吧
[导读]这一篇讲的是 动态库中调用动态库第一个要编译的动态库:PrintTest.h:extern int Add(int  x, int  y);  PrintTest.c#include "PrintTe

这一篇讲的是 动态库中调用动态库


第一个要编译的动态库:

PrintTest.h:

extern int Add(int  x, int  y);  



PrintTest.c

#include "PrintTest.h"  
  
int  Add(int  x, int  y)  
{  
    return x + y;  
}  


Android.mk:

LOCAL_PATH:= $(call my-dir)   
include $(CLEAR_VARS)  
LOCAL_MODULE    := print_share 
LOCAL_SRC_FILES := PrintTest.c   
include $(BUILD_SHARED_LIBRARY)  


运行ndk-build

编译出来的文件在 objlocalarmeabi 文件夹,而不是libs文件夹那个!特别要注意。。。。。。。。。。


现在来编译第二个动态库,他来调用第一个动态库

user.c:

#include "PrintTest.h"  
#include


Android.mk:

LOCAL_PATH:= $(call my-dir)  
  
# 需要把动态库导入 
#  
include $(CLEAR_VARS)  
LOCAL_MODULE    := print_share 
LOCAL_SRC_FILES := libprint_share.so 
include $(PREBUILT_SHARED_LIBRARY)  
  
# 第二个为动态库,在动态库中使用我们编译的动态库
 
include $(CLEAR_VARS)  
LOCAL_MODULE    := libuse  
LOCAL_SRC_FILES := Use.c  
LOCAL_SHARED_LIBRARIES := libprint_share
include $(BUILD_SHARED_LIBRARY)  


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭