I have solved it! ```cmake if(CMAKE_SYSTEM_NAME MATCHES Emscripten) set(CMAKE_EXECUTABLE_SUFFIX ".html" CACHE INTERNAL "")
#SET(EMSCRIPTEN_LINK_FLAGS "-lwebsocket.js") target_link_options("${EXECUTABLE_NAME}" PRIVATE "-lwebsocket.js") ``` On Sun, Jul 7, 2024 at 5:37 AM Ivan Enzhaev <8observ...@gmail.com> wrote: > rajsite helped here: > https://discord.com/channels/453584038356058112/590215642444202044/1259309132440277072 > I should use a loop. I try SDL3 with this template: > https://github.com/Ravbug/sdl3-sample I need to add -lwebsocket.js to > CMakeLists.txt. I try this: SET(EMSCRIPTEN_LINK_FLAGS "-lwebsocket.js") > But it didn't help > > On Sun, Jul 7, 2024 at 4:39 AM Ivan Enzhaev <8observ...@gmail.com> wrote: > >> Hello, >> >> I try to run the shorter version this example: >> https://gist.github.com/nus/564e9e57e4c107faa1a45b8332c265b9 >> >> I 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) >> ``` >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "emscripten-discuss" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/emscripten-discuss/_gTgnzwnWWU/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> emscripten-discuss+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/emscripten-discuss/212285fa-314f-4ac5-9e55-248132892f86n%40googlegroups.com >> <https://groups.google.com/d/msgid/emscripten-discuss/212285fa-314f-4ac5-9e55-248132892f86n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAPxskvGuBhyWUS60hGqqWUGXA%2B_TbfQqWiZNg4j3vEGvv%2BB3pg%40mail.gmail.com.