William
William

Reputation: 531

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?

Upvotes: 3

Views: 5958

Answers (2)

moodboom
moodboom

Reputation: 6882

I think lately, up to v2.0, libwebsockets went through some big refactoring, changing interface names from libwebsockets_... to lws_... for example. I need a C++ wrapper for it, if I don't find an updated one I may write my own. Wish it were more stable, maybe v2.0 will give us that.

Upvotes: 0

user2149991
user2149991

Reputation: 21

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);
//------

Upvotes: 2

Related Questions