ARM平台移植libevent-2.0.22-stable

系统环境:Ubuntu 14.04.3 LTS
源码:libevent-2.0.22-stable.tar.gz

交叉编译环境:arm-none-linux-gnueabi-

 

[zhaojq@virtual-machine]# tar -zxvf libevent-2.0.22-stable.tar.gz
[zhaojq@virtual-machine]# cd libevent-2.0.22-stable/

[zhaojq@virtual-machine]# ./configure --prefix=/home/zhaojq/libevent --host=arm-none-linux CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++

[zhaojq@virtual-machine]# make

[zhaojq@virtual-machine]# make install

生成成功

 

交叉编译后的文件在/home/zhaojq/libevent目录下
[zhaojq@virtual-machine libevent]# ls
bin  include  lib


libevent头文件在include目录
[zhaojq@virtual-machine libevent/include]# ls
evdns.h  event2  event.h  evhttp.h  evrpc.h  evutil.h


交叉编译后的动态库文件在lib目录
[zhaojq@virtual-machine libevent/lib]# ls
libevent-2.0.so.5           libevent_extra-2.0.so.5.1.9    libevent_openssl.so
libevent-2.0.so.5.1.9       libevent_extra.a               libevent_pthreads-2.0.so.5
libevent.a                  libevent_extra.la              libevent_pthreads-2.0.so.5.1.9
libevent_core-2.0.so.5      libevent_extra.so              libevent_pthreads.a
libevent_core-2.0.so.5.1.9  libevent.la                    libevent_pthreads.la
libevent_core.a             libevent_openssl-2.0.so.5      libevent_pthreads.so
libevent_core.la            libevent_openssl-2.0.so.5.1.9  libevent.so
libevent_core.so            libevent_openssl.a             pkgconfig
libevent_extra-2.0.so.5     libevent_openssl.la

 

编译test实例
[zhaojq@virtual-machine]# vim libevent_test.cpp

#include   
#include   
#include   
  
#include   
#include   
#include   
#include   
#include   

// (default)  
#define HTTP_CONTENT_TYPE_URL_ENCODED "application/json;charset=UTF-8"
// (use for files: picture, mp3, tar-file etc.)                                          
#define HTTP_CONTENT_TYPE_FORM_DATA "multipart/form-data"                   
// (use for plain text)  
#define HTTP_CONTENT_TYPE_TEXT_PLAIN "text/plain"  
  
#define REQUEST_POST_FLAG 2  
#define REQUEST_GET_FLAG 3  
  
struct http_request_method {  
	struct evhttp_uri *uri;  
	struct event_base *base;
	struct evhttp_connection *cn;  
	struct evhttp_request *req;  
};

struct http_request_get:public http_request_method{   
};  
  
struct http_request_post:public http_request_method{
	char *token;
	char *content_type;
	char *post_data;  
};  
  
/************************** Ahead Declare ******************************/  
void http_requset_post_cb(struct evhttp_request *req, struct http_request_post *http_req_post);
//void http_requset_get_cb(struct evhttp_request *req, void *arg);  
int start_url_request_get(struct http_request_get *http_req_get);
int start_url_request_post(struct http_request_post *http_req_post);
  
/************************** Tools Function ******************************/  
static inline void print_request_head_info(struct evkeyvalq *header)  
{  
    struct evkeyval *first_node = header->tqh_first;  
    while (first_node) {  
        printf("key:%s  value:%s\n", first_node->key, first_node->value);  
        first_node = first_node->next.tqe_next;  
    }  
}  

/************************************************************ 
Function: print_uri_parts_info
Author: Zhaojq
Version: 2.0
Date: 2016/05/17
Description: 打印URI参数

Called By: http_request_new

History:
	

[zhaojq@virtual-machine]# arm-none-linux-gnueabi-g++ -levent -I/home/zhaojq/libevent/include -L/home/zhaojq/libevent/lib -o libevent_test libevent.cpp
编译通过,在当前目录生成libevent_test可执行文件

 

将/home/zhaojq/libevent目录下的所有文件和pkgconfig目录都拷贝到ARM设备上文件系统的/lib目录,
libevent_test拷贝到ARM设备上

 

执行./libevent_test,移植成功。

 

你可能感兴趣的:(ARM平台移植)