c++ - g++无法编译带有libevent和libcurl的cpp
伊谢尔伦
伊谢尔伦 2017-04-17 11:07:15
0
2
806

运行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都已经安装了.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

모든 응답(2)
阿神
g++ proxyevent.cpp -levent -lcurl 
左手右手慢动作

用felix021的答案是可行的,不过需要把
#include <event2/event.h> #include <event2/http.h>
改成
#include <event.h> #include <evhttp.h>
就这样.

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿