gpt4 book ai didi

c - libwebsockets 教程问题 : ‘libwebsocket_internal_extensions’ undeclared and error: too many arguments to function ‘libwebsocket_create_context’

转载 作者:太空宇宙 更新时间:2023-11-03 23:31:07 27 4
gpt4 key购买 nike

我安装了 libwebsockets,然后我想尝试来自 http://martinsikora.com/libwebsockets-simple-http-server 的教程中的代码.从提供的 Gist 中复制代码,然后将其粘贴到编辑器中,然后使用 gcc -Wall -c "server.c"-lwebsockets 对其进行编译。我收到以下错误:server.c:115:43: error: 'libwebsocket_internal_extensions' undeclared (first use in this function)server.c:116:43: error: too many函数“libwebsocket_create_context”的参数

如何解决这些错误?

最佳答案

检查websocket库的路径是否正确(可以找到库)

我猜函数 libwebsocket_create_context() 改变了它的参数。查看 libwebsockets 示例 test-server.c:

现在应该是这样的:

/* old Version:
context = libwebsocket_create_context(port, interface, protocols,
libwebsocket_internal_extensions,
cert_path, key_path, -1, -1, opts);
*/

//-- new Version:
struct lws_context_creation_info info;

memset(&info, 0, sizeof info);
info.port = port;
info.iface = interface;
info.protocols = protocols;
info.extensions = libwebsocket_get_internal_extensions();
//if (!use_ssl) {
info.ssl_cert_filepath = NULL;
info.ssl_private_key_filepath = NULL;
//} else {
// info.ssl_cert_filepath = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem";
// info.ssl_private_key_filepath = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem";
//}
info.gid = -1;
info.uid = -1;
info.options = opts;

context = libwebsocket_create_context(&info);
//------

关于c - libwebsockets 教程问题 : ‘libwebsocket_internal_extensions’ undeclared and error: too many arguments to function ‘libwebsocket_create_context’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15181265/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com