Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libwebsockets tutorial issue: ‘libwebsocket_internal_extensions’ undeclared and error: too many arguments to function ‘libwebsocket_create_context’

I installed libwebsockets, and then I wanted try out the code from the tutorial at http://martinsikora.com/libwebsockets-simple-http-server. Copying the code from Gist provided, I then pasted it into an editor, then compiled it with gcc -Wall -c "server.c" -lwebsockets. I get the following errors: server.c:115:43: error: ‘libwebsocket_internal_extensions’ undeclared (first use in this function) and server.c:116:43: error: too many arguments to function ‘libwebsocket_create_context’.

How do I resolve those errors?

like image 604
William Avatar asked Apr 24 '26 00:04

William


1 Answers

Check if the path to the websocket library is correct (the library can be found)

I guess the function libwebsocket_create_context() changed its parameters. Take a look at the libwebsockets example test-server.c:

It should be something like that now:

/* 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);
//------
like image 97
user2149991 Avatar answered Apr 25 '26 20:04

user2149991



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!