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

 枫殇忆华年 发布于 2022-11-08 06:08

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

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

    2022-11-12 01:58 回答
  • g++ proxyevent.cpp -levent -lcurl 
    
    2022-11-12 01:58 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有