当前位置:   article > 正文

ubuntu下使用ndk编译libevnet

ubuntu下使用ndk编译libevnet
libevent源码编译
源码的获取

http://www.ffmpeg.club/libevent.html 这是看夏老师课堂获取的,以后也要学他的课,所以就用整个源码编译,减少问题出现

编译静态库

https://blog.csdn.net/weixin_28927079/article/details/109380748 大概上是参考这篇博客操作的,额外的修改会在下面提到

  在目录下增加Android.mk文件

  1. LOCAL_PATH := $(call my-dir)
  2. include $(CLEAR_VARS)
  3. LOCAL_ARM_MODE := arm
  4. LOCAL_MODULE := libevent
  5. ANDROID := true
  6. LIB_SRC := \
  7. event.c \
  8. evthread.c \
  9. buffer.c \
  10. bufferevent.c \
  11. bufferevent_filter.c \
  12. bufferevent_pair.c \
  13. listener.c \
  14. bufferevent_ratelim.c \
  15. evmap.c \
  16. log.c \
  17. evutil.c \
  18. evutil_rand.c \
  19. evutil_time.c \
  20. select.c \
  21. poll.c \
  22. epoll.c \
  23. signal.c \
  24. event_tagging.c \
  25. http.c \
  26. evdns.c \
  27. evrpc.c \
  28. bufferevent_sock.c \
  29. strlcpy.c
  30. LOCAL_SRC_FILES := $(LIB_SRC)
  31. LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
  32. $(LOCAL_PATH)/compat
  33. LOCAL_CFLAGS += -pie -fPIE -static -fPIC
  34. include $(BUILD_SHARED_LIBRARY) # 需要修改为 include $(BUILD_STATIC_LIBRARY)

  继续增加Application.mk文件

  1. APP_STL := c++_static
  2. APP_CPPFLAGS := -frtti -std=c++11
  3. APP_ABI := armeabi-v7a arm64-v8a #我这边编译器就是用 arm64-v8a 这个
  4. APP_BUILD_SCRIPT := Android.mk

  修改配置文件event2/event-config.h,如果没有就新建一个,这个文件后面也是要修改的

  1. /* event2/event-config.h
  2. *
  3. * This file was generated by autoconf when libevent was built, and post-
  4. * processed by Libevent so that its macros would have a uniform prefix.
  5. *
  6. * DO NOT EDIT THIS FILE.
  7. *
  8. * Do not rely on macros in this file existing in later versions.
  9. */
  10. #ifndef EVENT2_EVENT_CONFIG_H_INCLUDED_
  11. #define EVENT2_EVENT_CONFIG_H_INCLUDED_
  12. /* config.h. Generated from config.h.in by configure. */
  13. /* config.h.in. Generated from configure.ac by autoheader. */
  14. /* Define if libevent should build without support for a debug mode */
  15. /* #undef EVENT__DISABLE_DEBUG_MODE */
  16. /* Define if libevent should not allow replacing the mm functions */
  17. /* #undef EVENT__DISABLE_MM_REPLACEMENT */
  18. /* Define if libevent should not be compiled with thread support */
  19. /* #undef EVENT__DISABLE_THREAD_SUPPORT */
  20. /* Define to 1 if you have the `accept4' function. */
  21. #define EVENT__HAVE_ACCEPT4 1
  22. /* Define to 1 if you have the `arc4random' function. */
  23. /* #undef EVENT__HAVE_ARC4RANDOM */
  24. /* Define to 1 if you have the `arc4random_buf' function. */
  25. /* #undef EVENT__HAVE_ARC4RANDOM_BUF */
  26. /* Define to 1 if you have the <arpa/inet.h> header file. */
  27. #define EVENT__HAVE_ARPA_INET_H 1
  28. /* Define to 1 if you have the `clock_gettime' function. */
  29. #define EVENT__HAVE_CLOCK_GETTIME 1
  30. /* Define to 1 if you have the declaration of `CTL_KERN', and to 0 if you
  31. don't. */
  32. #define EVENT__HAVE_DECL_CTL_KERN 1
  33. /* Define to 1 if you have the declaration of `KERN_ARND', and to 0 if you
  34. don't. */
  35. #define EVENT__HAVE_DECL_KERN_ARND 0
  36. /* Define to 1 if you have the declaration of `KERN_RANDOM', and to 0 if you
  37. don't. */
  38. #define EVENT__HAVE_DECL_KERN_RANDOM 1
  39. /* Define to 1 if you have the declaration of `RANDOM_UUID', and to 0 if you
  40. don't. */
  41. #define EVENT__HAVE_DECL_RANDOM_UUID 1
  42. /* Define if /dev/poll is available */
  43. /* #undef EVENT__HAVE_DEVPOLL */
  44. /* Define to 1 if you have the <dlfcn.h> header file. */
  45. #define EVENT__HAVE_DLFCN_H 1
  46. /* Define if your system supports the epoll system calls */
  47. #define EVENT__HAVE_EPOLL 1
  48. /* Define to 1 if you have the `epoll_create1' function. */
  49. #define EVENT__HAVE_EPOLL_CREATE1 1
  50. /* Define to 1 if you have the `epoll_ctl' function. */
  51. #define EVENT__HAVE_EPOLL_CTL 1
  52. /* Define to 1 if you have the <errno.h> header file. */
  53. #define EVENT__HAVE_ERRNO_H 1
  54. /* Define to 1 if you have ERR_remove_thread_stat(). */
  55. #define EVENT__HAVE_ERR_REMOVE_THREAD_STATE 1
  56. /* Define to 1 if you have the `eventfd' function. */
  57. #define EVENT__HAVE_EVENTFD 1
  58. /* Define if your system supports event ports */
  59. /* #undef EVENT__HAVE_EVENT_PORTS */
  60. /* Define to 1 if you have the `fcntl' function. */
  61. #define EVENT__HAVE_FCNTL 1
  62. /* Define to 1 if you have the <fcntl.h> header file. */
  63. #define EVENT__HAVE_FCNTL_H 1
  64. /* Define to 1 if the system has the type `fd_mask'. */
  65. #define EVENT__HAVE_FD_MASK 1
  66. /* Do we have getaddrinfo()? */
  67. #define EVENT__HAVE_GETADDRINFO 1
  68. /* Define to 1 if you have the `getegid' function. */
  69. #define EVENT__HAVE_GETEGID 1
  70. /* Define to 1 if you have the `geteuid' function. */
  71. #define EVENT__HAVE_GETEUID 1
  72. /* Define this if you have any gethostbyname_r() */
  73. /* #undef EVENT__HAVE_GETHOSTBYNAME_R */
  74. /* Define this if gethostbyname_r takes 3 arguments */
  75. /* #undef EVENT__HAVE_GETHOSTBYNAME_R_3_ARG */
  76. /* Define this if gethostbyname_r takes 5 arguments */
  77. /* #undef EVENT__HAVE_GETHOSTBYNAME_R_5_ARG */
  78. /* Define this if gethostbyname_r takes 6 arguments */
  79. /* #undef EVENT__HAVE_GETHOSTBYNAME_R_6_ARG */
  80. /* Define to 1 if you have the `getifaddrs' function. */
  81. #define EVENT__HAVE_GETIFADDRS 1
  82. /* Define to 1 if you have the `getnameinfo' function. */
  83. #define EVENT__HAVE_GETNAMEINFO 1
  84. /* Define to 1 if you have the `getprotobynumber' function. */
  85. #define EVENT__HAVE_GETPROTOBYNUMBER 1
  86. /* Define to 1 if you have the `getservbyname' function. */
  87. #define EVENT__HAVE_GETSERVBYNAME 1
  88. /* Define to 1 if you have the `gettimeofday' function. */
  89. #define EVENT__HAVE_GETTIMEOFDAY 1
  90. /* Define to 1 if you have the <ifaddrs.h> header file. */
  91. #define EVENT__HAVE_IFADDRS_H 1
  92. /* Define to 1 if you have the `inet_ntop' function. */
  93. #define EVENT__HAVE_INET_NTOP 1
  94. /* Define to 1 if you have the `inet_pton' function. */
  95. #define EVENT__HAVE_INET_PTON 1
  96. /* Define to 1 if you have the <inttypes.h> header file. */
  97. #define EVENT__HAVE_INTTYPES_H 1
  98. /* Define to 1 if you have the `issetugid' function. */
  99. /* #undef EVENT__HAVE_ISSETUGID */
  100. /* Define to 1 if you have the `kqueue' function. */
  101. /* #undef EVENT__HAVE_KQUEUE */
  102. /* Define if the system has zlib */
  103. /* #undef EVENT__HAVE_LIBZ */
  104. /* Define to 1 if you have the `mach_absolute_time' function. */
  105. /* #undef EVENT__HAVE_MACH_ABSOLUTE_TIME */
  106. /* Define to 1 if you have the <mach/mach_time.h> header file. */
  107. /* #undef EVENT__HAVE_MACH_MACH_TIME_H */
  108. /* Define to 1 if you have the <memory.h> header file. */
  109. #define EVENT__HAVE_MEMORY_H 1
  110. /* Define to 1 if you have the `mmap' function. */
  111. #define EVENT__HAVE_MMAP 1
  112. /* Define to 1 if you have the `nanosleep' function. */
  113. #define EVENT__HAVE_NANOSLEEP 1
  114. /* Define to 1 if you have the <netdb.h> header file. */
  115. #ifndef WIN32
  116. #define EVENT__HAVE_NETDB_H 1
  117. #endif
  118. /* Define to 1 if you have the <netinet/in6.h> header file. */
  119. /* #undef EVENT__HAVE_NETINET_IN6_H */
  120. /* Define to 1 if you have the <netinet/in.h> header file. */
  121. #define EVENT__HAVE_NETINET_IN_H 1
  122. /* Define to 1 if you have the <netinet/tcp.h> header file. */
  123. #define EVENT__HAVE_NETINET_TCP_H 1
  124. /* Define if the system has openssl */
  125. #define EVENT__HAVE_OPENSSL 1
  126. /* Define to 1 if you have the `pipe' function. */
  127. #define EVENT__HAVE_PIPE 1
  128. /* Define to 1 if you have the `pipe2' function. */
  129. #define EVENT__HAVE_PIPE2 1
  130. /* Define to 1 if you have the `poll' function. */
  131. #define EVENT__HAVE_POLL 1
  132. /* Define to 1 if you have the <poll.h> header file. */
  133. #define EVENT__HAVE_POLL_H 1
  134. /* Define to 1 if you have the `port_create' function. */
  135. /* #undef EVENT__HAVE_PORT_CREATE */
  136. /* Define to 1 if you have the <port.h> header file. */
  137. /* #undef EVENT__HAVE_PORT_H */
  138. /* Define if you have POSIX threads libraries and header files. */
  139. /* #undef EVENT__HAVE_PTHREAD */
  140. /* Define if we have pthreads on this system */
  141. #define EVENT__HAVE_PTHREADS 1
  142. /* Define to 1 if you have the `putenv' function. */
  143. #define EVENT__HAVE_PUTENV 1
  144. /* Define to 1 if the system has the type `sa_family_t'. */
  145. #define EVENT__HAVE_SA_FAMILY_T 1
  146. /* Define to 1 if you have the `select' function. */
  147. #define EVENT__HAVE_SELECT 1
  148. /* Define to 1 if you have the `sendfile' function. */
  149. #define EVENT__HAVE_SENDFILE 1
  150. /* Define to 1 if you have the `setenv' function. */
  151. #define EVENT__HAVE_SETENV 1
  152. /* Define if F_SETFD is defined in <fcntl.h> */
  153. #define EVENT__HAVE_SETFD 1
  154. /* Define to 1 if you have the `setrlimit' function. */
  155. #define EVENT__HAVE_SETRLIMIT 1
  156. /* Define to 1 if you have the `sigaction' function. */
  157. #define EVENT__HAVE_SIGACTION 1
  158. /* Define to 1 if you have the `signal' function. */
  159. #define EVENT__HAVE_SIGNAL 1
  160. /* Define to 1 if you have the `splice' function. */
  161. #define EVENT__HAVE_SPLICE 1
  162. /* Define to 1 if you have the <stdarg.h> header file. */
  163. #define EVENT__HAVE_STDARG_H 1
  164. /* Define to 1 if you have the <stddef.h> header file. */
  165. #define EVENT__HAVE_STDDEF_H 1
  166. /* Define to 1 if you have the <stdint.h> header file. */
  167. #define EVENT__HAVE_STDINT_H 1
  168. /* Define to 1 if you have the <stdlib.h> header file. */
  169. #define EVENT__HAVE_STDLIB_H 1
  170. /* Define to 1 if you have the <strings.h> header file. */
  171. #define EVENT__HAVE_STRINGS_H 1
  172. /* Define to 1 if you have the <string.h> header file. */
  173. #define EVENT__HAVE_STRING_H 1
  174. /* Define to 1 if you have the `strlcpy' function. */
  175. /* #undef EVENT__HAVE_STRLCPY */
  176. /* Define to 1 if you have the `strsep' function. */
  177. #define EVENT__HAVE_STRSEP 1
  178. /* Define to 1 if you have the `strtok_r' function. */
  179. #define EVENT__HAVE_STRTOK_R 1
  180. /* Define to 1 if you have the `strtoll' function. */
  181. #define EVENT__HAVE_STRTOLL 1
  182. /* Define to 1 if the system has the type `struct addrinfo'. */
  183. #define EVENT__HAVE_STRUCT_ADDRINFO 1
  184. /* Define to 1 if the system has the type `struct in6_addr'. */
  185. #define EVENT__HAVE_STRUCT_IN6_ADDR 1
  186. /* Define to 1 if `s6_addr16' is a member of `struct in6_addr'. */
  187. #define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1
  188. /* Define to 1 if `s6_addr32' is a member of `struct in6_addr'. */
  189. #define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1
  190. /* Define to 1 if the system has the type `struct sockaddr_in6'. */
  191. #define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1
  192. /* Define to 1 if `sin6_len' is a member of `struct sockaddr_in6'. */
  193. /* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */
  194. /* Define to 1 if `sin_len' is a member of `struct sockaddr_in'. */
  195. /* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
  196. /* Define to 1 if the system has the type `struct sockaddr_storage'. */
  197. #define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1
  198. /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */
  199. #define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
  200. /* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */
  201. /* #undef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */
  202. /* Define to 1 if the system has the type `struct so_linger'. */
  203. /* #undef EVENT__HAVE_STRUCT_SO_LINGER */
  204. /* Define to 1 if you have the `sysctl' function. */
  205. #define EVENT__HAVE_SYSCTL 1
  206. /* Define to 1 if you have the <sys/devpoll.h> header file. */
  207. /* #undef EVENT__HAVE_SYS_DEVPOLL_H */
  208. /* Define to 1 if you have the <sys/epoll.h> header file. */
  209. #define EVENT__HAVE_SYS_EPOLL_H 1
  210. /* Define to 1 if you have the <sys/eventfd.h> header file. */
  211. #define EVENT__HAVE_SYS_EVENTFD_H 1
  212. /* Define to 1 if you have the <sys/event.h> header file. */
  213. /* #undef EVENT__HAVE_SYS_EVENT_H */
  214. /* Define to 1 if you have the <sys/ioctl.h> header file. */
  215. #define EVENT__HAVE_SYS_IOCTL_H 1
  216. /* Define to 1 if you have the <sys/mman.h> header file. */
  217. #define EVENT__HAVE_SYS_MMAN_H 1
  218. /* Define to 1 if you have the <sys/param.h> header file. */
  219. #define EVENT__HAVE_SYS_PARAM_H 1
  220. /* Define to 1 if you have the <sys/queue.h> header file. */
  221. #define EVENT__HAVE_SYS_QUEUE_H 1
  222. /* Define to 1 if you have the <sys/resource.h> header file. */
  223. #define EVENT__HAVE_SYS_RESOURCE_H 1
  224. /* Define to 1 if you have the <sys/select.h> header file. */
  225. #define EVENT__HAVE_SYS_SELECT_H 1
  226. /* Define to 1 if you have the <sys/sendfile.h> header file. */
  227. #define EVENT__HAVE_SYS_SENDFILE_H 1
  228. /* Define to 1 if you have the <sys/socket.h> header file. */
  229. #define EVENT__HAVE_SYS_SOCKET_H 1
  230. /* Define to 1 if you have the <sys/stat.h> header file. */
  231. #define EVENT__HAVE_SYS_STAT_H 1
  232. /* Define to 1 if you have the <sys/sysctl.h> header file. */
  233. #ifndef ANDROID
  234. #define EVENT__HAVE_SYS_SYSCTL_H 1
  235. #endif
  236. /* Define to 1 if you have the <sys/timerfd.h> header file. */
  237. #define EVENT__HAVE_SYS_TIMERFD_H 1
  238. /* Define to 1 if you have the <sys/time.h> header file. */
  239. #ifndef WIN32
  240. #define EVENT__HAVE_SYS_TIME_H 1
  241. #endif
  242. /* Define to 1 if you have the <sys/types.h> header file. */
  243. #define EVENT__HAVE_SYS_TYPES_H 1
  244. /* Define to 1 if you have the <sys/uio.h> header file. */
  245. #define EVENT__HAVE_SYS_UIO_H 1
  246. /* Define to 1 if you have the <sys/wait.h> header file. */
  247. #define EVENT__HAVE_SYS_WAIT_H 1
  248. /* Define if TAILQ_FOREACH is defined in <sys/queue.h> */
  249. #define EVENT__HAVE_TAILQFOREACH 1
  250. /* Define if timeradd is defined in <sys/time.h> */
  251. #define EVENT__HAVE_TIMERADD 1
  252. /* Define if timerclear is defined in <sys/time.h> */
  253. #define EVENT__HAVE_TIMERCLEAR 1
  254. /* Define if timercmp is defined in <sys/time.h> */
  255. #define EVENT__HAVE_TIMERCMP 1
  256. /* Define to 1 if you have the `timerfd_create' function. */
  257. #define EVENT__HAVE_TIMERFD_CREATE 1
  258. /* Define if timerisset is defined in <sys/time.h> */
  259. #define EVENT__HAVE_TIMERISSET 1
  260. /* Define to 1 if the system has the type `uint16_t'. */
  261. #define EVENT__HAVE_UINT16_T 1
  262. /* Define to 1 if the system has the type `uint32_t'. */
  263. #define EVENT__HAVE_UINT32_T 1
  264. /* Define to 1 if the system has the type `uint64_t'. */
  265. #define EVENT__HAVE_UINT64_T 1
  266. /* Define to 1 if the system has the type `uint8_t'. */
  267. #define EVENT__HAVE_UINT8_T 1
  268. /* Define to 1 if the system has the type `uintptr_t'. */
  269. #define EVENT__HAVE_UINTPTR_T 1
  270. /* Define to 1 if you have the `umask' function. */
  271. #define EVENT__HAVE_UMASK 1
  272. /* Define to 1 if you have the <unistd.h> header file. */
  273. #define EVENT__HAVE_UNISTD_H 1
  274. /* Define to 1 if you have the `unsetenv' function. */
  275. #define EVENT__HAVE_UNSETENV 1
  276. /* Define to 1 if you have the `usleep' function. */
  277. #define EVENT__HAVE_USLEEP 1
  278. /* Define to 1 if you have the `vasprintf' function. */
  279. #define EVENT__HAVE_VASPRINTF 1
  280. /* Define if waitpid() supports WNOWAIT */
  281. /* #undef EVENT__HAVE_WAITPID_WITH_WNOWAIT */
  282. /* Define if kqueue works correctly with pipes */
  283. /* #undef EVENT__HAVE_WORKING_KQUEUE */
  284. /* Define to 1 if you have the <zlib.h> header file. */
  285. /* #undef EVENT__HAVE_ZLIB_H */
  286. /* Define to the sub-directory where libtool stores uninstalled libraries. */
  287. #define EVENT__LT_OBJDIR ".libs/"
  288. /* Numeric representation of the version */
  289. #define EVENT__NUMERIC_VERSION 0x02010800
  290. /* Name of package */
  291. #define EVENT__PACKAGE "libevent"
  292. /* Define to the address where bug reports for this package should be sent. */
  293. #define EVENT__PACKAGE_BUGREPORT ""
  294. /* Define to the full name of this package. */
  295. #define EVENT__PACKAGE_NAME "libevent"
  296. /* Define to the full name and version of this package. */
  297. #define EVENT__PACKAGE_STRING "libevent 2.1.8-stable"
  298. /* Define to the one symbol short name of this package. */
  299. #define EVENT__PACKAGE_TARNAME "libevent"
  300. /* Define to the home page for this package. */
  301. #define EVENT__PACKAGE_URL ""
  302. /* Define to the version of this package. */
  303. #define EVENT__PACKAGE_VERSION "2.1.8-stable"
  304. /* Define to necessary symbol if this constant uses a non-standard name on
  305. your system. */
  306. /* #undef EVENT__PTHREAD_CREATE_JOINABLE */
  307. /* The size of `int', as computed by sizeof. */
  308. #define EVENT__SIZEOF_INT 4
  309. /* The size of `long', as computed by sizeof. */
  310. #define EVENT__SIZEOF_LONG 8
  311. /* The size of `long long', as computed by sizeof. */
  312. #define EVENT__SIZEOF_LONG_LONG 8
  313. /* The size of `off_t', as computed by sizeof. */
  314. #define EVENT__SIZEOF_OFF_T 8
  315. /* The size of `pthread_t', as computed by sizeof. */
  316. #define EVENT__SIZEOF_PTHREAD_T 8
  317. /* The size of `short', as computed by sizeof. */
  318. #define EVENT__SIZEOF_SHORT 2
  319. /* The size of `size_t', as computed by sizeof. */
  320. #define EVENT__SIZEOF_SIZE_T 8
  321. /* The size of `void *', as computed by sizeof. */
  322. #define EVENT__SIZEOF_VOID_P 8
  323. /* Define to 1 if you have the ANSI C header files. */
  324. #define EVENT__STDC_HEADERS 1
  325. /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
  326. #define EVENT__TIME_WITH_SYS_TIME 1
  327. /* Enable extensions on AIX 3, Interix. */
  328. #ifndef EVENT___ALL_SOURCE
  329. # define EVENT___ALL_SOURCE 1
  330. #endif
  331. /* Enable GNU extensions on systems that have them. */
  332. #ifndef EVENT___GNU_SOURCE
  333. # define EVENT___GNU_SOURCE 1
  334. #endif
  335. /* Enable threading extensions on Solaris. */
  336. #ifndef EVENT___POSIX_PTHREAD_SEMANTICS
  337. # define EVENT___POSIX_PTHREAD_SEMANTICS 1
  338. #endif
  339. /* Enable extensions on HP NonStop. */
  340. #ifndef EVENT___TANDEM_SOURCE
  341. # define EVENT___TANDEM_SOURCE 1
  342. #endif
  343. /* Enable general extensions on Solaris. */
  344. #ifndef EVENT____EXTENSIONS__
  345. # define EVENT____EXTENSIONS__ 1
  346. #endif
  347. /* Version number of package */
  348. #define EVENT__VERSION "2.1.8-stable"
  349. /* Enable large inode numbers on Mac OS X 10.5. */
  350. #ifndef EVENT___DARWIN_USE_64_BIT_INODE
  351. # define EVENT___DARWIN_USE_64_BIT_INODE 1
  352. #endif
  353. /* Number of bits in a file offset, on hosts where this is settable. */
  354. /* #undef EVENT___FILE_OFFSET_BITS */
  355. /* Define for large files, on AIX-style hosts. */
  356. /* #undef EVENT___LARGE_FILES */
  357. /* Define to 1 if on MINIX. */
  358. /* #undef EVENT___MINIX */
  359. /* Define to 2 if the system does not provide POSIX.1 features except with
  360. this defined. */
  361. /* #undef EVENT___POSIX_1_SOURCE */
  362. /* Define to 1 if you need to in order for `stat' and other things to work. */
  363. /* #undef EVENT___POSIX_SOURCE */
  364. /* Define to appropriate substitue if compiler doesnt have __func__ */
  365. /* #undef EVENT____func__ */
  366. /* Define to empty if `const' does not conform to ANSI C. */
  367. /* #undef EVENT__const */
  368. /* Define to `__inline__' or `__inline' if that's what the C compiler
  369. calls it, or to nothing if 'inline' is not supported under any name. */
  370. #ifndef EVENT____cplusplus
  371. /* #undef EVENT__inline */
  372. #endif
  373. /* Define to `int' if <sys/types.h> does not define. */
  374. /* #undef EVENT__pid_t */
  375. /* Define to `unsigned int' if <sys/types.h> does not define. */
  376. /* #undef EVENT__size_t */
  377. /* Define to unsigned int if you dont have it */
  378. /* #undef EVENT__socklen_t */
  379. /* Define to `int' if <sys/types.h> does not define. */
  380. /* #undef EVENT__ssize_t */
  381. #ifdef ANDROID
  382. #undef EVENT__HAVE_ARC4RANDOM
  383. #undef EVENT__HAVE_ARC4RANDOM_BUF
  384. #undef EVENT__HAVE_FD_MASK
  385. #undef EVENT__HAVE_SYS_TIMERFD_H
  386. #undef EVENT__HAVE_EPOLL_CREATE
  387. #undef EVENT__HAVE_GETIFADDRS
  388. #endif
  389. #endif /* event2/event-config.h */

  配置完后,开始进行编译,ndk-build.cmd路径根据实际情况修改

  1. D:\Android-SDK\ndk\21.3.6528147\ndk-build.cmd NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
  2. #ndk-build.cmd是android中的可执行文件
第一个报错以及解决
  1. Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.
  2. [arm64-v8a] Compile : event <= event.c
  3. ./event.c:28:10: fatal error: 'evconfig-private.h' file not found
  4. #include "evconfig-private.h"
  5. ^~~~~~~~~~~~~~~~~~~~

  解决方法: 把Android.mk当前目录下的\WIN32-Code\nmake\evconfig-private.h拷贝到Android.mk所在目录下

第二个报错以及解决
  1. ./epoll.c:148:23: error: use of undeclared identifier 'EPOLL_CLOEXEC'
  2. epfd = epoll_create1(EPOLL_CLOEXEC);
  3. ^

  解决方法: 将event2/event-config.h目录下的#define EVENT__HAVE_EPOLL_CREATE1 1注释掉

第三个报错以及解决

  1. error: static declaration of ‘arc4random_addrandom’ follows non-static declaration

增加定义 #define EVENT__HAVE_ARC4RANDOM 1

编译结果

  在\obj\local\arm64-v8a目录下获得libevent.a

openssl源码编译

https://github.com/aluvalasuman/OpenSSL1.0.1cForAndroid

  直接用github上面整理好的工程编译就行了,编译方法和上述一样,最后会生成libcrypto.alibssl.a

带着openssl编译libevent

  修改libevent目录下的Android.mk,增加一行如下

  1. LOCAL_PATH := $(call my-dir)
  2. include $(CLEAR_VARS)
  3. LOCAL_ARM_MODE := arm
  4. LOCAL_MODULE := libevent
  5. ANDROID := true
  6. LIB_SRC := \
  7. event.c \
  8. evthread.c \
  9. buffer.c \
  10. bufferevent.c \
  11. bufferevent_filter.c \
  12. bufferevent_pair.c \
  13. listener.c \
  14. bufferevent_ratelim.c \
  15. evmap.c \
  16. log.c \
  17. evutil.c \
  18. evutil_rand.c \
  19. evutil_time.c \
  20. select.c \
  21. poll.c \
  22. epoll.c \
  23. signal.c \
  24. event_tagging.c \
  25. http.c \
  26. evdns.c \
  27. evrpc.c \
  28. bufferevent_sock.c \
  29. strlcpy.c
  30. LOCAL_SRC_FILES := $(LIB_SRC)
  31. LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
  32. $(LOCAL_PATH)/compat
  33. OPENSSL_DIR := ./openssl-lib <=========================================增加这行,路径自己设置
  34. LOCAL_CFLAGS += -pie -fPIE -static -fPIC
  35. include $(BUILD_STATIC_LIBRARY)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/443745?site
推荐阅读
相关标签
  

闽ICP备14008679号