Hello,
I try to run the shorter version this example:
https://gist.github.com/nus/564e9e57e4c107faa1a45b8332c265b9I compile with this command:
emcc -lwebsocket.js -g src/client/main.cpp -o public/main.html
It compiles without problems:
```
emcc -lwebsocket.js -g src/client/main.cpp -o public/main.html cache:INFO: generating system asset: symbol_lists/f1b6fbba91d4f7c17e21f323c8df509adb00db34.json... (this will be cached in "C:\emsdk\upstream\emscripten\cache\symbol_lists\f1b6fbba91d4f7c17e21f323c8df509adb00db34.json" for subsequent builds) ```
```cpp
#include <emscripten/websocket.h>
#include <iostream>
EM_BOOL onopen(int eventType, const EmscriptenWebSocketOpenEvent *websocketEvent, void *userData) {
std::cout << "onopen" << std::endl;
return EM_TRUE;
}
int main()
{
EmscriptenWebSocketCreateAttributes ws_attrs = {
"wss://localhost:3000",
NULL,
EM_TRUE
};
EMSCRIPTEN_WEBSOCKET_T ws = emscripten_websocket_new(&ws_attrs);
emscripten_websocket_set_onopen_callback(ws, NULL, onopen);
return 0;
}
```
But I have the error in the browser:
```
main.js:666 Aborted(malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS)
main.js:685 Uncaught (in promise) RuntimeError: Aborted(malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS)
at abort (main.js:685:11)
at _malloc (main.js:379:3)
at _emscripten_websocket_set_onopen_callback_on_thread (main.js:1219:45)
at __original_main (main.wasm:0x156f)
at main (main.wasm:0x2584)
at main.js:723:22
at callMain (main.js:4625:15)
at doRun (main.js:4675:23)
at run (main.js:4690:5)
at runCaller (main.js:4610:19)
```