欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

android移栽libcurl和libsqlite3

更新时间: 2014-01-05 02:07:10 责任编辑: Author_N1

 

Android移植libcurl和libsqlite3

移植libcurl:

1、网上下载curl-7.32.0.tar.gz,解压;

2、下载主目录下configure,因为接下来编译的时候要用到curl_config.h,这个是在configure时生成的:

./configure --host=arm-linux CC=arm-linux-gnueabi-gcc

3、在主目录下编写Android.mk:

LOCAL_PATH := $(call my-dir)
CURL_TOP := $(LOCAL_PATH)
include $(CLEAR_VARS)
include $(CURL_TOP)/lib/Android.mk

4、在lib目录下编写Android.mk,因为如果要生成libcurl.so,如果生成curl可执行文件的话,要把src下面也加上:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
file.c timeval.c base64.c hostip.c progress.c formdata.c     \
cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c       \
ldap.c ssluse.c version.c getenv.c escape.c mprintf.c telnet.c        \
netrc.c getinfo.c transfer.c strequal.c easy.c security.c krb4.c      \
curl_fnmatch.c fileinfo.c ftplistparser.c wildcard.c krb5.c           \
memdebug.c http_chunks.c strtok.c connect.c llist.c hash.c multi.c    \
content_encoding.c share.c http_digest.c md4.c md5.c  \
http_negotiate.c inet_pton.c strtoofft.c strerror.c amigaos.c         \
hostasyn.c hostip4.c hostip6.c hostsyn.c inet_ntop.c parsedate.c      \
select.c gtls.c sslgen.c tftp.c splay.c strdup.c socks.c ssh.c nss.c  \
qssl.c rawstr.c curl_addrinfo.c socks_gssapi.c socks_sspi.c           \
curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c    \
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c polarssl.c         \
polarssl_threadlock.c curl_rtmp.c openldap.c curl_gethostname.c       \
gopher.c axtls.c idn_win32.c http_negotiate_sspi.c cyassl.c           \
http_proxy.c non-ascii.c asyn-ares.c asyn-thread.c curl_gssapi.c      \
curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_ntlm_msgs.c          \
curl_sasl.c curl_schannel.c curl_multibyte.c curl_darwinssl.c         \
hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c      \
gskit.c
LOCAL_C_INCLUDES :=./ \
        $(LOCAL_PATH)/../include 
#       /opt/arm-linux-gnueabi/arm-linux-gnueabi/libc/usr/include/ \
#       /opt/arm-linux-gnueabi/arm-linux-gnueabi/libc/usr/include/arm-linux-gnueabi/

LOCAL_CFLAGS :=  -DHAVE_CONFIG_H -I../include/curl -I../include -I../include -I../lib -I../lib -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -fvisibility=hidden -O2 -Wno-system-headers 

 -fPIC -DPIC 

LOCAL_LDLIBS:= -lc -ldl 
LOCAL_MODULE:=libcurl
include $(BUILD_SHARED_LIBRARY)

5、接下来用ndk编译或者copy到源码环境中编译,会出现如下错误:

/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:44:23: fatal error: ifaddrs.h: No such file or directory
compilation terminated.

在if2ip.c中我们发现ifaddrs.h是在宏HAVE_IFADDRS_H中的,在lib/curl_config.h中把这个宏注释掉就ok了,
再编译会有:

/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:47:23: fatal error: stropts.h: No such file or directory
compilation terminated.
同样在在lib/curl_config.h中把HAVE_STROPTS_H宏注释掉就ok了,
再编译,还有错误:
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c: In function 'Curl_if_is_interface_name':
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:75:47: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:76:29: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c: In function 'Curl_if2ip':
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:97:47: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:98:15: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:99:17: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:100:33: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:127:51: error: dereferencing pointer to incomplete type
/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/jni/lib/if2ip.c:135:36: error: dereferencing pointer to incomplete type
make: *** [/home/usrhome/johnny.he/androidworkspace/jni_compile/jni_curl-7.32.2/obj/local/armeabi/objs/curl/if2ip.o] Error 1

找到if2ip.c文件的47行,发现Curl_if_is_interface_name()函数是在HAVE_GETIFADDRS中的,同样在lib/curl_config.h中把这个宏注释掉就ok。
再编译就生成了liburl.so了。


移植libsqlite3

1、网上下载sqlite-autoconf-3080002.tar.gz,解压。
2、在主目录中写Android.mk:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
        shell.c \
        sqlite3.c \

LOCAL_C_INCLUDES :=./ 

LOCAL_CFLAGS := -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.8.0.2\" "-DPACKAGE_STRING=\"sqlite 3.8.0.2\"" -DPACKAGE_BUGREPORT=

\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.8.0.2\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -

DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -

DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -

DHAVE_STRERROR_R=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 

LOCAL_LDLIBS:= -lc -ldl 
LOCAL_MODULE:=libsqlite3
include $(BUILD_SHARED_LIBRARY)

就ok了。
3、编译。

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:07:10
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/5834/
本文WWW.DOC100.NET DOC100.NET版权所有。