0

I'm following Mongoose webserver on Github (https://github.com/cesanta/mongoose) and I want to test the websocket sample code.

Here are the codes that I copied:

enter image description here

Unfortunately when I run the code, it returns the following errors:

websocket.obj : error LNK2001: unresolved external symbol _find_embedded_file
C:\ProjectFolder\WebsocketDemo.exe : fatal error LNK1120: 1 unresolved externals

Did I miss something?

mpromonet
  • 11,326
  • 43
  • 62
  • 91
benjtupas
  • 610
  • 9
  • 25

1 Answers1

0

The makefile of the examples explain what is missing

There is a rule that generate websocket_html.c that embeded the websocket.html inside a c file (it defines the missing find_embedded_file function).

websocket_html.c: websocket.html 
     perl mkdata.pl $< > $@

If you prefer to give access to the websocket.html file, this could be done modifying the websocket.c sample

  1. Setting the document_root option

     mg_set_option(server, "document_root", ".");
    
  2. Not handle the html url in the user handler

     static int send_reply(struct mg_connection *conn) {
         if (conn->is_websocket) {
         ...
         } else {
             return MG_FALSE; // mongoose will open file specified by the url
         }
     }
    
mpromonet
  • 11,326
  • 43
  • 62
  • 91