android-ndk-r10 编译 curl

这里只讲curl是如何编译的关于ssl zlib 其他的自行查找方式

下载源curl源码 http://curl.haxx.se/download.html 

C库:curl-7.46.0

目标平台:android

编译平台:win7

编译工具:ndk r10

编译过程

1、随手创建一个eclipse的android项目,记得在源码中增加jni目录,写过ndk的朋友都知道

2、构建curl编译目录,下面所指向的目录均以 上面创建的jni目录为根结构,因为最后我们执行ndk-build命令也是在此目录

{1}把正解好的curl源码解压,把目录改名为curl,并复制到jni目录下

{2}在jni目录创建 Android.mk 并复制下面的内容

 1 LOCAL_PATH:= $(call my-dir)
 2 
 3 CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline 
 4  -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long 
 5  -Wfloat-equal -Wno-multichar -Wsign-compare -Wno-format-nonliteral 
 6  -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement 
 7  -Wno-system-headers -DHAVE_CONFIG_H
 8 
 9 include $(CLEAR_VARS)
10 include $(LOCAL_PATH)/curl/lib/Makefile.inc
11 
12 
13 LOCAL_SRC_FILES := $(addprefix curl/lib/,$(CSOURCES))
14 LOCAL_CFLAGS += $(CFLAGS)
15 LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include/ $(LOCAL_PATH)/curl/lib
16 
17 LOCAL_COPY_HEADERS_TO := libcurl
18 LOCAL_COPY_HEADERS := $(addprefix curl/include/curl/,$(HHEADERS))
19 
20 LOCAL_MODULE:= libcurl
21 
22 include $(BUILD_STATIC_LIBRARY)
View Code

{3}在jni目录创建 Application.mk 并复制下面的内容

APP_ABI :=  x86 armeabi armeabi-v7a

最后目录结构如下 

jni
|-Android.mk 
|-Application.mk
|-curl(这里为curl源码目录)

3 、构建config.h文件 其实就是在linux下使用./configurl生成的config.h文件 在这里我们手动构建

 在jni/curl/lib/下 创建curl_config.h文件 并复制下面源码直接覆盖就好了 源码来源于 http://www.cnblogs.com/stratrail/archive/2013/04/12/3016663.html 感谢这位大神,虽然我用他介绍的方式没有编译成功

  1 /* lib/curl_config.h.  Generated from curl_config.h.in by configure.  */
  2 /* lib/curl_config.h.in.  Generated from configure.ac by autoheader.  */
  3 
  4 /* when building libcurl itself */
  5 /* #undef BUILDING_LIBCURL */
  6 
  7 /* Location of default ca bundle */
  8 /* #undef CURL_CA_BUNDLE */
  9 
 10 /* Location of default ca path */
 11 /* #undef CURL_CA_PATH */
 12 
 13 /* to disable cookies support */
 14 /* #undef CURL_DISABLE_COOKIES */
 15 
 16 /* to disable cryptographic authentication */
 17 /* #undef CURL_DISABLE_CRYPTO_AUTH */
 18 
 19 /* to disable DICT */
 20 /* #undef CURL_DISABLE_DICT */
 21 
 22 /* to disable FILE */
 23 /* #undef CURL_DISABLE_FILE */
 24 
 25 /* to disable FTP */
 26 #define CURL_DISABLE_FTP 1
 27 
 28 /* to disable HTTP */
 29 /* #undef CURL_DISABLE_HTTP */
 30 
 31 /* to disable IMAP */
 32 #define CURL_DISABLE_IMAP 1
 33 
 34 /* to disable LDAP */
 35 #define CURL_DISABLE_LDAP 1
 36 
 37 /* to disable LDAPS */
 38 #define CURL_DISABLE_LDAPS 1
 39 
 40 /* to disable POP3 */
 41 #define CURL_DISABLE_POP3 1
 42 
 43 /* to disable proxies */
 44 /* #undef CURL_DISABLE_PROXY */
 45 
 46 /* to disable RTSP */
 47 #define CURL_DISABLE_RTSP 1
 48 
 49 /* to disable SMTP */
 50 #define CURL_DISABLE_SMTP 1
 51 
 52 /* to disable TELNET */
 53 #define CURL_DISABLE_TELNET 1
 54 
 55 /* to disable TFTP */
 56 #define CURL_DISABLE_TFTP 1
 57 
 58 /* to disable verbose strings */
 59 /* #undef CURL_DISABLE_VERBOSE_STRINGS */
 60 
 61 /* to make a symbol visible */
 62 /* #undef CURL_EXTERN_SYMBOL */
 63 
 64 /* to enable hidden symbols */
 65 /* #undef CURL_HIDDEN_SYMBOLS */
 66 
 67 /* W$ LDAP with non-W$ compiler */
 68 /* #undef CURL_LDAP_HYBRID */
 69 
 70 /* Use W$ LDAP implementation */
 71 /* #undef CURL_LDAP_WIN */
 72 
 73 /* when not building a shared library */
 74 /* #undef CURL_STATICLIB */
 75 
 76 /* your Entropy Gathering Daemon socket pathname */
 77 /* #undef EGD_SOCKET */
 78 
 79 /* Define if you want to enable IPv6 support */
 80 /* #undef ENABLE_IPV6 */
 81 
 82 /* Define to the type qualifier of arg 1 for getnameinfo. */
 83 #define GETNAMEINFO_QUAL_ARG1 const
 84 
 85 /* Define to the type of arg 1 for getnameinfo. */
 86 #define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
 87 
 88 /* Define to the type of arg 2 for getnameinfo. */
 89 #define GETNAMEINFO_TYPE_ARG2 socklen_t
 90 
 91 /* Define to the type of args 4 and 6 for getnameinfo. */
 92 #define GETNAMEINFO_TYPE_ARG46 size_t
 93 
 94 /* Define to the type of arg 7 for getnameinfo. */
 95 #define GETNAMEINFO_TYPE_ARG7 int
 96 
 97 /* Specifies the number of arguments to getservbyport_r */
 98 /* #undef GETSERVBYPORT_R_ARGS */
 99 
100 /* Specifies the size of the buffer to pass to getservbyport_r */
101 /* #undef GETSERVBYPORT_R_BUFSIZE */
102 
103 /* Define to 1 if you have the alarm function. */
104 #define HAVE_ALARM 1
105 
106 /* Define to 1 if you have the <alloca.h> header file. */
107 #define HAVE_ALLOCA_H 1
108 
109 /* Define to 1 if you have the <arpa/inet.h> header file. */
110 #define HAVE_ARPA_INET_H 1
111 
112 /* Define to 1 if you have the <arpa/tftp.h> header file. */
113 /* #undef HAVE_ARPA_TFTP_H */
114 
115 /* Define to 1 if you have the <assert.h> header file. */
116 #define HAVE_ASSERT_H 1
117 
118 /* Define to 1 if you have the basename function. */
119 #define HAVE_BASENAME 1
120 
121 /* Define to 1 if bool is an available type. */
122 #define HAVE_BOOL_T 1
123 
124 /* Define to 1 if you have the clock_gettime function and monotonic timer. */
125 #define HAVE_CLOCK_GETTIME_MONOTONIC 1
126 
127 /* Define to 1 if you have the closesocket function. */
128 /* #undef HAVE_CLOSESOCKET */
129 
130 /* Define to 1 if you have the CloseSocket camel case function. */
131 /* #undef HAVE_CLOSESOCKET_CAMEL */
132 
133 /* Define to 1 if you have the connect function. */
134 #define HAVE_CONNECT 1
135 
136 /* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */
137 /* #undef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA */
138 
139 /* Define to 1 if you have the <crypto.h> header file. */
140 /* #undef HAVE_CRYPTO_H */
141 
142 /* Define to 1 if you have the <des.h> header file. */
143 /* #undef HAVE_DES_H */
144 
145 /* Define to 1 if you have the <dlfcn.h> header file. */
146 #define HAVE_DLFCN_H 1
147 
148 /* Define to 1 if you have the `ENGINE_cleanup' function. */
149 /* #undef HAVE_ENGINE_CLEANUP */
150 
151 /* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */
152 /* #undef HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
153 
154 /* Define to 1 if you have the <errno.h> header file. */
155 #define HAVE_ERRNO_H 1
156 
157 /* Define to 1 if you have the <err.h> header file. */
158 /* #undef HAVE_ERR_H */
159 
160 /* Define to 1 if you have the fcntl function. */
161 #define HAVE_FCNTL 1
162 
163 /* Define to 1 if you have the <fcntl.h> header file. */
164 #define HAVE_FCNTL_H 1
165 
166 /* Define to 1 if you have a working fcntl O_NONBLOCK function. */
167 #define HAVE_FCNTL_O_NONBLOCK 1
168 
169 /* Define to 1 if you have the fdopen function. */
170 #define HAVE_FDOPEN 1
171 
172 /* Define to 1 if you have the `fork' function. */
173 #define HAVE_FORK 1
174 
175 /* Define to 1 if you have the freeaddrinfo function. */
176 #define HAVE_FREEADDRINFO 1
177 
178 /* Define to 1 if you have the freeifaddrs function. */
179 /* #undef HAVE_FREEIFADDRS */
180 
181 /* Define to 1 if you have the ftruncate function. */
182 #define HAVE_FTRUNCATE 1
183 
184 /* Define to 1 if you have a working getaddrinfo function. */
185 #define HAVE_GETADDRINFO 1
186 
187 /* Define to 1 if the getaddrinfo function is threadsafe. */
188 #define HAVE_GETADDRINFO_THREADSAFE 1
189 
190 /* Define to 1 if you have the `geteuid' function. */
191 #define HAVE_GETEUID 1
192 
193 /* Define to 1 if you have the gethostbyaddr function. */
194 #define HAVE_GETHOSTBYADDR 1
195 
196 /* Define to 1 if you have the gethostbyaddr_r function. */
197 /* #undef HAVE_GETHOSTBYADDR_R */
198 
199 /* gethostbyaddr_r() takes 5 args */
200 /* #undef HAVE_GETHOSTBYADDR_R_5 */
201 
202 /* gethostbyaddr_r() takes 7 args */
203 /* #undef HAVE_GETHOSTBYADDR_R_7 */
204 
205 /* gethostbyaddr_r() takes 8 args */
206 /* #undef HAVE_GETHOSTBYADDR_R_8 */
207 
208 /* Define to 1 if you have the gethostbyname function. */
209 #define HAVE_GETHOSTBYNAME 1
210 
211 /* Define to 1 if you have the gethostbyname_r function. */
212 #define HAVE_GETHOSTBYNAME_R 1
213 
214 /* gethostbyname_r() takes 3 args */
215 /* #undef HAVE_GETHOSTBYNAME_R_3 */
216 
217 /* gethostbyname_r() takes 5 args */
218 /* #undef HAVE_GETHOSTBYNAME_R_5 */
219 
220 /* gethostbyname_r() takes 6 args */
221 #define HAVE_GETHOSTBYNAME_R_6 1
222 
223 /* Define to 1 if you have the gethostname function. */
224 #define HAVE_GETHOSTNAME 1
225 
226 /* Define to 1 if you have a working getifaddrs function. */
227 /* #undef HAVE_GETIFADDRS */
228 
229 /* Define to 1 if you have the getnameinfo function. */
230 #define HAVE_GETNAMEINFO 1
231 
232 /* Define to 1 if you have the `getpass_r' function. */
233 /* #undef HAVE_GETPASS_R */
234 
235 /* Define to 1 if you have the `getppid' function. */
236 #define HAVE_GETPPID 1
237 
238 /* Define to 1 if you have the `getprotobyname' function. */
239 #define HAVE_GETPROTOBYNAME 1
240 
241 /* Define to 1 if you have the `getpwuid' function. */
242 #define HAVE_GETPWUID 1
243 
244 /* Define to 1 if you have the `getrlimit' function. */
245 #define HAVE_GETRLIMIT 1
246 
247 /* Define to 1 if you have the getservbyport_r function. */
248 /* #undef HAVE_GETSERVBYPORT_R */
249 
250 /* Define to 1 if you have the `gettimeofday' function. */
251 #define HAVE_GETTIMEOFDAY 1
252 
253 /* Define to 1 if you have a working glibc-style strerror_r function. */
254 /* #undef HAVE_GLIBC_STRERROR_R */
255 
256 /* Define to 1 if you have a working gmtime_r function. */
257 #define HAVE_GMTIME_R 1
258 
259 /* if you have the gssapi libraries */
260 /* #undef HAVE_GSSAPI */
261 
262 /* Define to 1 if you have the <gssapi/gssapi_generic.h> header file. */
263 /* #undef HAVE_GSSAPI_GSSAPI_GENERIC_H */
264 
265 /* Define to 1 if you have the <gssapi/gssapi.h> header file. */
266 /* #undef HAVE_GSSAPI_GSSAPI_H */
267 
268 /* Define to 1 if you have the <gssapi/gssapi_krb5.h> header file. */
269 /* #undef HAVE_GSSAPI_GSSAPI_KRB5_H */
270 
271 /* if you have the GNU gssapi libraries */
272 /* #undef HAVE_GSSGNU */
273 
274 /* if you have the Heimdal gssapi libraries */
275 /* #undef HAVE_GSSHEIMDAL */
276 
277 /* if you have the MIT gssapi libraries */
278 /* #undef HAVE_GSSMIT */
279 
280 /* Define to 1 if you have the `idna_strerror' function. */
281 /* #undef HAVE_IDNA_STRERROR */
282 
283 /* Define to 1 if you have the `idn_free' function. */
284 /* #undef HAVE_IDN_FREE */
285 
286 /* Define to 1 if you have the <idn-free.h> header file. */
287 /* #undef HAVE_IDN_FREE_H */
288 
289 /* Define to 1 if you have the <ifaddrs.h> header file. */
290 /* #undef HAVE_IFADDRS_H */
291 
292 /* Define to 1 if you have the `inet_addr' function. */
293 #define HAVE_INET_ADDR 1
294 
295 /* Define to 1 if you have the inet_ntoa_r function. */
296 /* #undef HAVE_INET_NTOA_R */
297 
298 /* inet_ntoa_r() takes 2 args */
299 /* #undef HAVE_INET_NTOA_R_2 */
300 
301 /* inet_ntoa_r() takes 3 args */
302 /* #undef HAVE_INET_NTOA_R_3 */
303 
304 /* Define to 1 if you have a IPv6 capable working inet_ntop function. */
305 #define HAVE_INET_NTOP 1
306 
307 /* Define to 1 if you have a IPv6 capable working inet_pton function. */
308 #define HAVE_INET_PTON 1
309 
310 /* Define to 1 if you have the <inttypes.h> header file. */
311 #define HAVE_INTTYPES_H 1
312 
313 /* Define to 1 if you have the ioctl function. */
314 #define HAVE_IOCTL 1
315 
316 /* Define to 1 if you have the ioctlsocket function. */
317 /* #undef HAVE_IOCTLSOCKET */
318 
319 /* Define to 1 if you have the IoctlSocket camel case function. */
320 /* #undef HAVE_IOCTLSOCKET_CAMEL */
321 
322 /* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
323    */
324 /* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
325 
326 /* Define to 1 if you have a working ioctlsocket FIONBIO function. */
327 /* #undef HAVE_IOCTLSOCKET_FIONBIO */
328 
329 /* Define to 1 if you have a working ioctl FIONBIO function. */
330 #define HAVE_IOCTL_FIONBIO 1
331 
332 /* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
333 #define HAVE_IOCTL_SIOCGIFADDR 1
334 
335 /* Define to 1 if you have the <io.h> header file. */
336 /* #undef HAVE_IO_H */
337 
338 /* if you have the Kerberos4 libraries (including -ldes) */
339 /* #undef HAVE_KRB4 */
340 
341 /* Define to 1 if you have the `krb_get_our_ip_for_realm' function. */
342 /* #undef HAVE_KRB_GET_OUR_IP_FOR_REALM */
343 
344 /* Define to 1 if you have the <krb.h> header file. */
345 /* #undef HAVE_KRB_H */
346 
347 /* Define to 1 if you have the lber.h header file. */
348 /* #undef HAVE_LBER_H */
349 
350 /* Define to 1 if you have the ldapssl.h header file. */
351 /* #undef HAVE_LDAPSSL_H */
352 
353 /* Define to 1 if you have the ldap.h header file. */
354 /* #undef HAVE_LDAP_H */
355 
356 /* Use LDAPS implementation */
357 /* #undef HAVE_LDAP_SSL */
358 
359 /* Define to 1 if you have the ldap_ssl.h header file. */
360 /* #undef HAVE_LDAP_SSL_H */
361 
362 /* Define to 1 if you have the `ldap_url_parse' function. */
363 /* #undef HAVE_LDAP_URL_PARSE */
364 
365 /* Define to 1 if you have the <libgen.h> header file. */
366 #define HAVE_LIBGEN_H 1
367 
368 /* Define to 1 if you have the `idn' library (-lidn). */
369 /* #undef HAVE_LIBIDN */
370 
371 /* Define to 1 if you have the `resolv' library (-lresolv). */
372 /* #undef HAVE_LIBRESOLV */
373 
374 /* Define to 1 if you have the `resolve' library (-lresolve). */
375 /* #undef HAVE_LIBRESOLVE */
376 
377 /* Define to 1 if you have the `ssh2' library (-lssh2). */
378 /* #undef HAVE_LIBSSH2 */
379 
380 /* Define to 1 if you have the <libssh2.h> header file. */
381 /* #undef HAVE_LIBSSH2_H */
382 
383 /* Define to 1 if you have the `libssh2_version' function. */
384 /* #undef HAVE_LIBSSH2_VERSION */
385 
386 /* Define to 1 if you have the `ssl' library (-lssl). */
387 /* #undef HAVE_LIBSSL */
388 
389 /* if zlib is available */
390 /* #undef HAVE_LIBZ */
391 
392 /* Define to 1 if you have the <limits.h> header file. */
393 #define HAVE_LIMITS_H 1
394 
395 /* if your compiler supports LL */
396 #define HAVE_LL 1
397 
398 /* Define to 1 if you have the <locale.h> header file. */
399 #define HAVE_LOCALE_H 1
400 
401 /* Define to 1 if you have a working localtime_r function. */
402 #define HAVE_LOCALTIME_R 1
403 
404 /* Define to 1 if the compiler supports the 'long long' data type. */
405 #define HAVE_LONGLONG 1
406 
407 /* Define to 1 if you have the malloc.h header file. */
408 #define HAVE_MALLOC_H 1
409 
410 /* Define to 1 if you have the memory.h header file. */
411 #define HAVE_MEMORY_H 1
412 
413 /* Define to 1 if you have the memrchr function or macro. */
414 #define HAVE_MEMRCHR 1
415 
416 /* Define to 1 if you have the MSG_NOSIGNAL flag. */
417 #define HAVE_MSG_NOSIGNAL 1
418 
419 /* Define to 1 if you have the <netdb.h> header file. */
420 #define HAVE_NETDB_H 1
421 
422 /* Define to 1 if you have the <netinet/in.h> header file. */
423 #define HAVE_NETINET_IN_H 1
424 
425 /* Define to 1 if you have the <netinet/tcp.h> header file. */
426 #define HAVE_NETINET_TCP_H 1
427 
428 /* Define to 1 if you have the <net/if.h> header file. */
429 #define HAVE_NET_IF_H 1
430 
431 /* Define to 1 if NI_WITHSCOPEID exists and works. */
432 /* #undef HAVE_NI_WITHSCOPEID */
433 
434 /* if you have an old MIT gssapi library, lacking GSS_C_NT_HOSTBASED_SERVICE
435    */
436 /* #undef HAVE_OLD_GSSMIT */
437 
438 /* Define to 1 if you have the <openssl/crypto.h> header file. */
439 /* #undef HAVE_OPENSSL_CRYPTO_H */
440 
441 /* Define to 1 if you have the <openssl/engine.h> header file. */
442 /* #undef HAVE_OPENSSL_ENGINE_H */
443 
444 /* Define to 1 if you have the <openssl/err.h> header file. */
445 /* #undef HAVE_OPENSSL_ERR_H */
446 
447 /* Define to 1 if you have the <openssl/pem.h> header file. */
448 /* #undef HAVE_OPENSSL_PEM_H */
449 
450 /* Define to 1 if you have the <openssl/pkcs12.h> header file. */
451 /* #undef HAVE_OPENSSL_PKCS12_H */
452 
453 /* Define to 1 if you have the <openssl/rsa.h> header file. */
454 /* #undef HAVE_OPENSSL_RSA_H */
455 
456 /* Define to 1 if you have the <openssl/ssl.h> header file. */
457 /* #undef HAVE_OPENSSL_SSL_H */
458 
459 /* Define to 1 if you have the <openssl/x509.h> header file. */
460 /* #undef HAVE_OPENSSL_X509_H */
461 
462 /* Define to 1 if you have the <pem.h> header file. */
463 /* #undef HAVE_PEM_H */
464 
465 /* Define to 1 if you have the `perror' function. */
466 #define HAVE_PERROR 1
467 
468 /* Define to 1 if you have the `pipe' function. */
469 #define HAVE_PIPE 1
470 
471 /* if you have the function PK11_CreateGenericObject */
472 /* #undef HAVE_PK11_CREATEGENERICOBJECT */
473 
474 /* Define to 1 if you have a working poll function. */
475 #define HAVE_POLL 1
476 
477 /* If you have a fine poll */
478 #define HAVE_POLL_FINE 1
479 
480 /* Define to 1 if you have the <poll.h> header file. */
481 #define HAVE_POLL_H 1
482 
483 /* Define to 1 if you have a working POSIX-style strerror_r function. */
484 #define HAVE_POSIX_STRERROR_R 1
485 
486 /* Define to 1 if you have the <pwd.h> header file. */
487 #define HAVE_PWD_H 1
488 
489 /* Define to 1 if you have the `RAND_egd' function. */
490 /* #undef HAVE_RAND_EGD */
491 
492 /* Define to 1 if you have the `RAND_screen' function. */
493 /* #undef HAVE_RAND_SCREEN */
494 
495 /* Define to 1 if you have the `RAND_status' function. */
496 /* #undef HAVE_RAND_STATUS */
497 
498 /* Define to 1 if you have the recv function. */
499 #define HAVE_RECV 1
500 
501 /* Define to 1 if you have the recvfrom function. */
502 #define HAVE_RECVFROM 1
503 
504 /* Define to 1 if you have the <rsa.h> header file. */
505 /* #undef HAVE_RSA_H */
506 
507 /* Define to 1 if you have the select function. */
508 #define HAVE_SELECT 1
509 
510 /* Define to 1 if you have the send function. */
511 #define HAVE_SEND 1
512 
513 /* Define to 1 if you have the <setjmp.h> header file. */
514 #define HAVE_SETJMP_H 1
515 
516 /* Define to 1 if you have the `setlocale' function. */
517 #define HAVE_SETLOCALE 1
518 
519 /* Define to 1 if you have the `setmode' function. */
520 /* #undef HAVE_SETMODE */
521 
522 /* Define to 1 if you have the `setrlimit' function. */
523 #define HAVE_SETRLIMIT 1
524 
525 /* Define to 1 if you have the setsockopt function. */
526 #define HAVE_SETSOCKOPT 1
527 
528 /* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
529 /* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
530 
531 /* Define to 1 if you have the <sgtty.h> header file. */
532 #define HAVE_SGTTY_H 1
533 
534 /* Define to 1 if you have the sigaction function. */
535 #define HAVE_SIGACTION 1
536 
537 /* Define to 1 if you have the siginterrupt function. */
538 #define HAVE_SIGINTERRUPT 1
539 
540 /* Define to 1 if you have the signal function. */
541 /* #undef HAVE_SIGNAL */
542 
543 /* Define to 1 if you have the <signal.h> header file. */
544 #define HAVE_SIGNAL_H 1
545 
546 /* Define to 1 if you have the sigsetjmp function or macro. */
547 #define HAVE_SIGSETJMP 1
548 
549 /* Define to 1 if sig_atomic_t is an available typedef. */
550 #define HAVE_SIG_ATOMIC_T 1
551 
552 /* Define to 1 if sig_atomic_t is already defined as volatile. */
553 /* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
554 
555 /* Define to 1 if struct sockaddr_in6 has the sin6_scope_id member */
556 /* #undef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID */
557 
558 /* Define to 1 if you have the socket function. */
559 #define HAVE_SOCKET 1
560 
561 /* Define to 1 if you have the <socket.h> header file. */
562 /* #undef HAVE_SOCKET_H */
563 
564 /* Define this if you have the SPNEGO library fbopenssl */
565 /* #undef HAVE_SPNEGO */
566 
567 /* Define to 1 if you have the `SSL_get_shutdown' function. */
568 /* #undef HAVE_SSL_GET_SHUTDOWN */
569 
570 /* Define to 1 if you have the <ssl.h> header file. */
571 /* #undef HAVE_SSL_H */
572 
573 /* Define to 1 if you have the <stdbool.h> header file. */
574 #define HAVE_STDBOOL_H 1
575 
576 /* Define to 1 if you have the <stdint.h> header file. */
577 #define HAVE_STDINT_H 1
578 
579 /* Define to 1 if you have the <stdio.h> header file. */
580 #define HAVE_STDIO_H 1
581 
582 /* Define to 1 if you have the <stdlib.h> header file. */
583 #define HAVE_STDLIB_H 1
584 
585 /* Define to 1 if you have the strcasecmp function. */
586 #define HAVE_STRCASECMP 1
587 
588 /* Define to 1 if you have the strcasestr function. */
589 #define HAVE_STRCASESTR 1
590 
591 /* Define to 1 if you have the strcmpi function. */
592 /* #undef HAVE_STRCMPI */
593 
594 /* Define to 1 if you have the strdup function. */
595 #define HAVE_STRDUP 1
596 
597 /* Define to 1 if you have the strerror_r function. */
598 #define HAVE_STRERROR_R 1
599 
600 /* Define to 1 if you have the stricmp function. */
601 /* #undef HAVE_STRICMP */
602 
603 /* Define to 1 if you have the <strings.h> header file. */
604 #define HAVE_STRINGS_H 1
605 
606 /* Define to 1 if you have the <string.h> header file. */
607 #define HAVE_STRING_H 1
608 
609 /* Define to 1 if you have the strlcat function. */
610 #define HAVE_STRLCAT 1
611 
612 /* Define to 1 if you have the `strlcpy' function. */
613 /* #undef HAVE_STRLCPY */
614 
615 /* Define to 1 if you have the strncasecmp function. */
616 #define HAVE_STRNCASECMP 1
617 
618 /* Define to 1 if you have the strncmpi function. */
619 /* #undef HAVE_STRNCMPI */
620 
621 /* Define to 1 if you have the strnicmp function. */
622 /* #undef HAVE_STRNICMP */
623 
624 /* Define to 1 if you have the <stropts.h> header file. */
625 /* #undef HAVE_STROPTS_H */
626 
627 /* Define to 1 if you have the strstr function. */
628 #define HAVE_STRSTR 1
629 
630 /* Define to 1 if you have the strtok_r function. */
631 #define HAVE_STRTOK_R 1
632 
633 /* Define to 1 if you have the strtoll function. */
634 #define HAVE_STRTOLL 1
635 
636 /* if struct sockaddr_storage is defined */
637 #define HAVE_STRUCT_SOCKADDR_STORAGE 1
638 
639 /* Define to 1 if you have the timeval struct. */
640 #define HAVE_STRUCT_TIMEVAL 1
641 
642 /* Define to 1 if you have the <sys/filio.h> header file. */
643 /* #undef HAVE_SYS_FILIO_H */
644 
645 /* Define to 1 if you have the <sys/ioctl.h> header file. */
646 #define HAVE_SYS_IOCTL_H 1
647 
648 /* Define to 1 if you have the <sys/param.h> header file. */
649 #define HAVE_SYS_PARAM_H 1
650 
651 /* Define to 1 if you have the <sys/poll.h> header file. */
652 #define HAVE_SYS_POLL_H 1
653 
654 /* Define to 1 if you have the <sys/resource.h> header file. */
655 #define HAVE_SYS_RESOURCE_H 1
656 
657 /* Define to 1 if you have the <sys/select.h> header file. */
658 #define HAVE_SYS_SELECT_H 1
659 
660 /* Define to 1 if you have the <sys/socket.h> header file. */
661 #define HAVE_SYS_SOCKET_H 1
662 
663 /* Define to 1 if you have the <sys/sockio.h> header file. */
664 /* #undef HAVE_SYS_SOCKIO_H */
665 
666 /* Define to 1 if you have the <sys/stat.h> header file. */
667 #define HAVE_SYS_STAT_H 1
668 
669 /* Define to 1 if you have the <sys/time.h> header file. */
670 #define HAVE_SYS_TIME_H 1
671 
672 /* Define to 1 if you have the <sys/types.h> header file. */
673 #define HAVE_SYS_TYPES_H 1
674 
675 /* Define to 1 if you have the <sys/uio.h> header file. */
676 #define HAVE_SYS_UIO_H 1
677 
678 /* Define to 1 if you have the <sys/un.h> header file. */
679 #define HAVE_SYS_UN_H 1
680 
681 /* Define to 1 if you have the <sys/utime.h> header file. */
682 #define HAVE_SYS_UTIME_H 1
683 
684 /* Define to 1 if you have the <termios.h> header file. */
685 #define HAVE_TERMIOS_H 1
686 
687 /* Define to 1 if you have the <termio.h> header file. */
688 /* #undef HAVE_TERMIO_H */
689 
690 /* Define to 1 if you have the <time.h> header file. */
691 #define HAVE_TIME_H 1
692 
693 /* Define to 1 if you have the <tld.h> header file. */
694 /* #undef HAVE_TLD_H */
695 
696 /* Define to 1 if you have the `tld_strerror' function. */
697 /* #undef HAVE_TLD_STRERROR */
698 
699 /* Define to 1 if you have the `uname' function. */
700 #define HAVE_UNAME 1
701 
702 /* Define to 1 if you have the <unistd.h> header file. */
703 #define HAVE_UNISTD_H 1
704 
705 /* Define to 1 if you have the `utime' function. */
706 #define HAVE_UTIME 1
707 
708 /* Define to 1 if you have the <utime.h> header file. */
709 #define HAVE_UTIME_H 1
710 
711 /* Define to 1 if compiler supports C99 variadic macro style. */
712 #define HAVE_VARIADIC_MACROS_C99 1
713 
714 /* Define to 1 if compiler supports old gcc variadic macro style. */
715 #define HAVE_VARIADIC_MACROS_GCC 1
716 
717 /* Define to 1 if you have the winber.h header file. */
718 /* #undef HAVE_WINBER_H */
719 
720 /* Define to 1 if you have the windows.h header file. */
721 /* #undef HAVE_WINDOWS_H */
722 
723 /* Define to 1 if you have the winldap.h header file. */
724 /* #undef HAVE_WINLDAP_H */
725 
726 /* Define to 1 if you have the winsock2.h header file. */
727 /* #undef HAVE_WINSOCK2_H */
728 
729 /* Define to 1 if you have the winsock.h header file. */
730 /* #undef HAVE_WINSOCK_H */
731 
732 /* Define this symbol if your OS supports changing the contents of argv */
733 /* #undef HAVE_WRITABLE_ARGV */
734 
735 /* Define to 1 if you have the writev function. */
736 #define HAVE_WRITEV 1
737 
738 /* Define to 1 if you have the ws2tcpip.h header file. */
739 /* #undef HAVE_WS2TCPIP_H */
740 
741 /* Define to 1 if you have the <x509.h> header file. */
742 /* #undef HAVE_X509_H */
743 
744 /* if you have the zlib.h header file */
745 /* #undef HAVE_ZLIB_H */
746 
747 /* Define to the sub-directory in which libtool stores uninstalled libraries.
748    */
749 #define LT_OBJDIR ".libs/"
750 
751 /* Define to 1 if you are building a native Windows target. */
752 /* #undef NATIVE_WINDOWS */
753 
754 /* Define to 1 if you need the lber.h header file even with ldap.h */
755 /* #undef NEED_LBER_H */
756 
757 /* Define to 1 if you need the malloc.h header file even with stdlib.h */
758 /* #undef NEED_MALLOC_H */
759 
760 /* Define to 1 if you need the memory.h header file even with stdlib.h */
761 /* #undef NEED_MEMORY_H */
762 
763 /* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
764 /* #undef NEED_REENTRANT */
765 
766 /* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
767 /* #undef NEED_THREAD_SAFE */
768 
769 /* cpu-machine-OS */
770 #define OS "arm-unknown-linux-gnu"
771 
772 /* Name of package */
773 #define PACKAGE "curl"
774 
775 /* Define to the address where bug reports for this package should be sent. */
776 #define PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/"
777 
778 /* Define to the full name of this package. */
779 #define PACKAGE_NAME "curl"
780 
781 /* Define to the full name and version of this package. */
782 #define PACKAGE_STRING "curl -"
783 
784 /* Define to the one symbol short name of this package. */
785 #define PACKAGE_TARNAME "curl"
786 
787 /* Define to the home page for this package. */
788 /* #undef PACKAGE_URL */
789 
790 /* Define to the version of this package. */
791 #define PACKAGE_VERSION "-"
792 
793 /* a suitable file to read random data from */
794 /* #undef RANDOM_FILE */
795 
796 /* Define to the type of arg 1 for recvfrom. */
797 /* #undef RECVFROM_TYPE_ARG1 */
798 
799 /* Define to the type pointed by arg 2 for recvfrom. */
800 /* #undef RECVFROM_TYPE_ARG2 */
801 
802 /* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
803 /* #undef RECVFROM_TYPE_ARG2_IS_VOID */
804 
805 /* Define to the type of arg 3 for recvfrom. */
806 /* #undef RECVFROM_TYPE_ARG3 */
807 
808 /* Define to the type of arg 4 for recvfrom. */
809 /* #undef RECVFROM_TYPE_ARG4 */
810 
811 /* Define to the type pointed by arg 5 for recvfrom. */
812 /* #undef RECVFROM_TYPE_ARG5 */
813 
814 /* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
815 /* #undef RECVFROM_TYPE_ARG5_IS_VOID */
816 
817 /* Define to the type pointed by arg 6 for recvfrom. */
818 /* #undef RECVFROM_TYPE_ARG6 */
819 
820 /* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
821 /* #undef RECVFROM_TYPE_ARG6_IS_VOID */
822 
823 /* Define to the function return type for recvfrom. */
824 /* #undef RECVFROM_TYPE_RETV */
825 
826 /* Define to the type of arg 1 for recv. */
827 #define RECV_TYPE_ARG1 int
828 
829 /* Define to the type of arg 2 for recv. */
830 #define RECV_TYPE_ARG2 void *
831 
832 /* Define to the type of arg 3 for recv. */
833 #define RECV_TYPE_ARG3 size_t
834 
835 /* Define to the type of arg 4 for recv. */
836 #define RECV_TYPE_ARG4 unsigned int
837 
838 /* Define to the function return type for recv. */
839 #define RECV_TYPE_RETV ssize_t
840 
841 /* Define as the return type of signal handlers (`int' or `void'). */
842 #define RETSIGTYPE void
843 
844 /* Define to the type qualifier of arg 5 for select. */
845 #define SELECT_QUAL_ARG5 
846 
847 /* Define to the type of arg 1 for select. */
848 #define SELECT_TYPE_ARG1 int
849 
850 /* Define to the type of args 2, 3 and 4 for select. */
851 #define SELECT_TYPE_ARG234 fd_set *
852 
853 /* Define to the type of arg 5 for select. */
854 #define SELECT_TYPE_ARG5 struct timeval *
855 
856 /* Define to the function return type for select. */
857 #define SELECT_TYPE_RETV int
858 
859 /* Define to the type qualifier of arg 2 for send. */
860 #define SEND_QUAL_ARG2 const
861 
862 /* Define to the type of arg 1 for send. */
863 #define SEND_TYPE_ARG1 int
864 
865 /* Define to the type of arg 2 for send. */
866 #define SEND_TYPE_ARG2 void *
867 
868 /* Define to the type of arg 3 for send. */
869 #define SEND_TYPE_ARG3 size_t
870 
871 /* Define to the type of arg 4 for send. */
872 #define SEND_TYPE_ARG4 unsigned int
873 
874 /* Define to the function return type for send. */
875 #define SEND_TYPE_RETV ssize_t
876 
877 /* The size of `int', as computed by sizeof. */
878 #define SIZEOF_INT 4
879 
880 /* The size of `long', as computed by sizeof. */
881 #define SIZEOF_LONG 4
882 
883 /* The size of `off_t', as computed by sizeof. */
884 #define SIZEOF_OFF_T 4
885 
886 /* The size of `short', as computed by sizeof. */
887 #define SIZEOF_SHORT 2
888 
889 /* The size of `size_t', as computed by sizeof. */
890 #define SIZEOF_SIZE_T 4
891 
892 /* The size of `time_t', as computed by sizeof. */
893 #define SIZEOF_TIME_T 4
894 
895 /* The size of `void*', as computed by sizeof. */
896 #define SIZEOF_VOIDP 4
897 
898 /* Define to 1 if you have the ANSI C header files. */
899 #define STDC_HEADERS 1
900 
901 /* Define to the type of arg 3 for strerror_r. */
902 #define STRERROR_R_TYPE_ARG3 size_t
903 
904 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
905 #define TIME_WITH_SYS_TIME 1
906 
907 /* Define to enable c-ares support */
908 /* #undef USE_ARES */
909 
910 /* Define to disable non-blocking sockets. */
911 /* #undef USE_BLOCKING_SOCKETS */
912 
913 /* if GnuTLS is enabled */
914 /* #undef USE_GNUTLS */
915 
916 /* if libSSH2 is in use */
917 /* #undef USE_LIBSSH2 */
918 
919 /* If you want to build curl with the built-in manual */
920 /* #undef USE_MANUAL */
921 
922 /* if NSS is enabled */
923 /* #undef USE_NSS */
924 
925 /* if OpenSSL is in use */
926 /* #undef USE_OPENSSL */
927 
928 /* if SSL is enabled */
929 /* #undef USE_SSLEAY */
930 
931 /* Define to 1 if you are building a Windows target without large file
932    support. */
933 /* #undef USE_WIN32_LARGE_FILES */
934 
935 /* to enable SSPI support */
936 /* #undef USE_WINDOWS_SSPI */
937 
938 /* Define to 1 if using yaSSL in OpenSSL compatibility mode. */
939 /* #undef USE_YASSLEMUL */
940 
941 /* Version number of package */
942 #define VERSION "7.20.1"
943 
944 /* Define to avoid automatic inclusion of winsock.h */
945 /* #undef WIN32_LEAN_AND_MEAN */
946 
947 /* Define to 1 if OS is AIX. */
948 #ifndef _ALL_SOURCE
949 /* #  undef _ALL_SOURCE */
950 #endif
951 
952 /* Number of bits in a file offset, on hosts where this is settable. */
953 /* #undef _FILE_OFFSET_BITS */
954 
955 /* Define for large files, on AIX-style hosts. */
956 /* #undef _LARGE_FILES */
957 
958 /* Define to empty if `const' does not conform to ANSI C. */
959 /* #undef const */
960 
961 /* Type to use in place of in_addr_t when system does not provide it. */
962 /* #undef in_addr_t */
963 
964 /* Define to `__inline__' or `__inline' if that's what the C compiler
965    calls it, or to nothing if 'inline' is not supported under any name.  */
966 #ifndef __cplusplus
967 /* #undef inline */
968 #endif
969 
970 /* Define to `unsigned int' if <sys/types.h> does not define. */
971 /* #undef size_t */
972 
973 /* the signed version of size_t */
974 /* #undef ssize_t */
View Code

4、下面我们就打开cmd 窗口进入 android项目中的jni目录 

执行  ndk-bulid  激动人心的时刻就这样来临了 生成后的 静态库 在android项目中的 obj目录中

至此我也只是成功编译了静态库 有任何其他的问题 大家可以一起 到 25093009 NDK JNI android开发交流群,大家一起交流讨论

5、

关于静态编译似乎有个误区 我在尝试  

LOCAL_STATIC_LIBRARIES := $(LOCAL_PATH)/curl/$(TARGET_ARCH_ABI)/libcurl.a 

编译的时候 始终会提供找没有定义的函数 

一定需要这样子写

LOCAL_LDFLAGS := $(LOCAL_PATH)/curl/$(TARGET_ARCH_ABI)/libcurl.a

才会正常 但是ndk-build的时候会报一个警告 单单的忧伤 

贴一下测试项目的代码 

android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_LDLIBS            := -lm -llog 

LOCAL_MODULE            := curljni
LOCAL_LDFLAGS             := $(LOCAL_PATH)/curl/$(TARGET_ARCH_ABI)/libcurl.a
LOCAL_C_INCLUDES         += $(LOCAL_PATH)/curl/include $(LOCAL_PATH)/curl/lib
LOCAL_SRC_FILES    := 
                curljni.cpp

include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_ABI :=  x86 armeabi armeabi-v7a
#
APP_STL := gnustl_static
APP_CPPFLAGS += -fexceptions --std=c++11

curljni.cpp

// 调试      LOGI("  %d", len);
#include<android/log.h>  
#define LOG_TAG "debug"
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##args)
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, fmt, ##args)
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##args)

#include <jni.h>    
#include <string.h>
#include <string>
#include "curl/include/curl.h" 
using namespace std;

#ifdef __cplusplus
extern "C" {
#endif

  
//回调函数获取数据
size_t writeCallback(char* buf, size_t size, size_t nmemb, string* up) {
    for (int c = 0; c < size * nmemb; c++) {
        (*up).push_back(buf[c]);
    }
    return size * nmemb; //tell curl how many bytes we handled
}
             
jstring Java_com_example_crultest_JniUtil_Http( JNIEnv* env,jobject thiz,jstring imageurl) 
{  
  CURL *curl; 
  CURLcode res;  

  const char *weburl = (env)->GetStringUTFChars(imageurl, NULL);
  if (weburl == NULL) {
      return NULL;  
  }

    std::string strData;
 
  //初始化 curl_global_init可以不设置
  curl_global_init(CURL_GLOBAL_DEFAULT);
  curl = curl_easy_init(); 
  if(curl) { 
    curl_easy_setopt(curl, CURLOPT_URL, weburl); // 设置访问链接
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback); // 设置回调函数
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strData); //设置回调参数(在回调函数内可以调用)
    res = curl_easy_perform(curl); //执行获得curl返回参数用于判断成功与否
        /* always cleanup */ 
    curl_easy_cleanup(curl); 
    (env)->ReleaseStringUTFChars( imageurl, weburl);
    
 //清理 curl
   curl_global_cleanup(); 
 

    if(CURLE_OK != res) { 
            //失败
        LOGI("curl told us %d
", res);   
        return (env)->NewStringUTF("failed");
    }
    else
    {
        //成功
        LOGI("succesful
");   
        return (env)->NewStringUTF(strData.c_str());
    }
   }

   return (env)->NewStringUTF("failed");
}

#ifdef __cplusplus
}
#endif

测试项目jni 目录结构

jni
|-Android.mk 
|-Application.mk
|-curljni.cpp
|-curl(头文件,静态库所在目录)
|-armeabi(前一个项目生成的静态库存 位于obj目录中)
|-armeabi-v7a (前一个项目生成的静态库 位于obj目录中)
|-x86 (前一个项目生成的静态库 位于obj目录中)
|-include(来源于curl源码 自行复制)
|-lib(来源于curl源码 自行复制)
原文地址:https://www.cnblogs.com/qinsuixin/p/5023295.html