在windows上编译android版的libevent

2018-09-12  本文已影响0人  zhao_guang

1、下载libEvent,我用的是2.0.22

https://nchc.dl.sourceforge.net/project/levent/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz

2、为了避免麻烦,手工写一个event-config.h

cd libevent/include/event2/

新建一个event-config.h

#ifndef _EVENT2_EVENT_CONFIG_H_

#define _EVENT2_EVENT_CONFIG_H_

#define _EVENT_HAVE_SA_FAMILY_T 1

#define _EVENT_HAVE_SYS_SOCKET_H 1

#define _EVENT_HAVE_NETINET_IN_H 1

#define _EVENT_HAVE_SYS_TIME_H 1

#define _EVENT_HAVE_STDARG_H 1

#define _EVENT_HAVE_UNISTD_H 1

#define _EVENT_HAVE_NETINET_IN6_H 1

#define ARC4RANDOM_BUF 1

#define _EVENT_HAVE_EPOLL

//#define ARC4RANDOM_NOADDRANDOM 1

#define _EVENT_HAVE_STRLCPY 1

#define _EVENT_HAVE_STRSEP 1

#define _EVENT_HAVE_NETDB_H 1

#define _EVENT_HAVE_STRTOK_R 1

#define _EVENT_HAVE_FCNTL_H 1

#define _EVENT_HAVE_GETTIMEOFDAY 1

#define _EVENT_HAVE_INTTYPES_H 1

#define _EVENT_HAVE_MEMORY_H 1

#define _EVENT_HAVE_PUTENV 1

#define _EVENT_HAVE_SIGNAL 1

#define _EVENT_HAVE_STDARG_H 1

#define _EVENT_HAVE_STDDEF_H 1

#define _EVENT_HAVE_STDINT_H 1

#define _EVENT_HAVE_STDLIB_H 1

#define _EVENT_HAVE_STRINGS_H 1

#define _EVENT_HAVE_STRING_H 1

#define _EVENT_HAVE_STRTOLL 1

#define _EVENT_HAVE_STRUCT_IN6_ADDR 1

#define _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1

#define _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1

#define _EVENT_HAVE_STRUCT_SOCKADDR_IN6 1

#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE 1

#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1

#define _EVENT_HAVE_SYS_PARAM_H 1

#define _EVENT_HAVE_SYS_STAT_H 1

#define _EVENT_HAVE_SYS_TIME_H 1

#define _EVENT_HAVE_SYS_TYPES_H 1

#define _EVENT_HAVE_TIMERCLEAR 1

#define _EVENT_HAVE_TIMERCMP 1

#define _EVENT_HAVE_TIMERISSET 1

#define _EVENT_HAVE_UINT16_T 1

#define _EVENT_HAVE_UINT32_T 1

#define _EVENT_HAVE_UINT64_T 1

#define _EVENT_HAVE_UINT8_T 1

#define _EVENT_HAVE_UINTPTR_T 1

#define _EVENT_HAVE_UMASK 1

#define _EVENT_HAVE_UNISTD_H 1

#define _EVENT_LT_OBJDIR ".libs/"

#define _EVENT_NUMERIC_VERSION 0x02001600

#define _EVENT_PACKAGE "libevent"

#define _EVENT_PACKAGE_BUGREPORT ""

#define _EVENT_PACKAGE_NAME ""

#define _EVENT_PACKAGE_STRING ""

#define _EVENT_PACKAGE_TARNAME ""

#define _EVENT_PACKAGE_URL ""

#define _EVENT_PACKAGE_VERSION ""

#define _EVENT_SIZEOF_INT 4

#define _EVENT_SIZEOF_LONG 4

#define _EVENT_SIZEOF_LONG_LONG 8

#define _EVENT_SIZEOF_SHORT 2

#define _EVENT_SIZEOF_SIZE_T4

#define _EVENT_SIZEOF_VOID_P 4

#define _EVENT_STDC_HEADERS 1

#define _EVENT_TIME_WITH_SYS_TIME 1

#define _EVENT_VERSION "2.0.22-stable"

#ifndef _EVENT___cplusplus

#endif

#define _EVENT_socklen_t unsigned int

#endif /* event2/event-config.h */

3、屏蔽arc4random_buf

在libevent/arc4random.c中arc4random_buf定义前加#ifndef ARC4RANDOM_BUF,当然,之后要加#endif

4、在CMakeLists.txt中加

add_library( libevent

SHARED

src/main/cpp/libevent/buffer.c

src/main/cpp/libevent/bufferevent.c

src/main/cpp/libevent/bufferevent_filter.c

src/main/cpp/libevent/bufferevent_pair.c

src/main/cpp/libevent/bufferevent_ratelim.c

src/main/cpp/libevent/bufferevent_sock.c

src/main/cpp/libevent/epoll.c

src/main/cpp/libevent/epoll_sub.c

src/main/cpp/libevent/evdns.c

src/main/cpp/libevent/event.c

src/main/cpp/libevent/event_tagging.c

src/main/cpp/libevent/evmap.c

src/main/cpp/libevent/evrpc.c

src/main/cpp/libevent/evthread.c

src/main/cpp/libevent/evthread_pthread.c

src/main/cpp/libevent/evutil.c

src/main/cpp/libevent/evutil_rand.c

src/main/cpp/libevent/http.c

src/main/cpp/libevent/listener.c

src/main/cpp/libevent/log.c

src/main/cpp/libevent/poll.c

src/main/cpp/libevent/select.c

src/main/cpp/libevent/signal.c

src/main/cpp/libevent/strlcpy.c )

上一篇下一篇

猜你喜欢

热点阅读