首页 > 开发 > C++ > 正文

g++无法编译带有libevent和libcurl的cpp

2017-09-11 21:35:39  来源: 网友分享

运行g++ -L/usr/include -levent -lcurl proxyevent.cpp提示:

proxyevent.cpp: 在函数‘size_t write_data(void*, size_t, size_t, void*)’中:proxyevent.cpp:25:47: 错误:‘evbuffer_add’在此作用域中尚未声明proxyevent.cpp: 在函数‘void cb_handler(evhttp_request*, void*)’中:proxyevent.cpp:31:37: 错误:‘evbuffer_new’在此作用域中尚未声明proxyevent.cpp:32:38: 错误:‘evhttp_request_uri’在此作用域中尚未声明proxyevent.cpp:35:16: 错误:对不完全的类型‘struct evhttp_request’的非法使用In file included from proxyevent.cpp:2:0:/usr/local/include/event2/http.h:68:8: 错误:‘struct evhttp_request’的前向声明proxyevent.cpp:46:41: 错误:对不完全的类型‘struct evhttp_request’的非法使用In file included from proxyevent.cpp:2:0:/usr/local/include/event2/http.h:68:8: 错误:‘struct evhttp_request’的前向声明proxyevent.cpp:46:55: 错误:‘EVBUFFER_LENGTH’在此作用域中尚未声明proxyevent.cpp:49:44: 错误:对不完全的类型‘struct evhttp_request’的非法使用In file included from proxyevent.cpp:2:0:/usr/local/include/event2/http.h:68:8: 错误:‘struct evhttp_request’的前向声明proxyevent.cpp:49:58: 错误:‘EVBUFFER_DATA’在此作用域中尚未声明proxyevent.cpp:64:30: 错误:对不完全的类型‘struct evhttp_request’的非法使用In file included from proxyevent.cpp:2:0:/usr/local/include/event2/http.h:68:8: 错误:‘struct evhttp_request’的前向声明proxyevent.cpp:66:26: 错误:对不完全的类型‘struct evhttp_request’的非法使用In file included from proxyevent.cpp:2:0:/usr/local/include/event2/http.h:68:8: 错误:‘struct evhttp_request’的前向声明proxyevent.cpp:69:25: 错误:‘evbuffer_free’在此作用域中尚未声明proxyevent.cpp: 在函数‘int main(int, char**)’中:proxyevent.cpp:80:16: 错误:‘event_init’在此作用域中尚未声明proxyevent.cpp:81:49: 错误:‘evhttp_start’在此作用域中尚未声明proxyevent.cpp:90:20: 错误:‘event_dispatch’在此作用域中尚未声明

求解,libcurl,libcurl-devel,libevent,libevent-devel都已经安装了.

解决方案

g++ proxyevent.cpp -levent -lcurl