我安装了 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 arguments to function ‘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/