Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiling and running tests/websocket/websocket.c gives missing function #8061

Closed
merlinzerbe opened this issue Feb 11, 2019 · 3 comments
Closed

Comments

@merlinzerbe
Copy link

Problem description

I want to use the WebSockets api introduced in #7670. There is a test file for the api
in tests/websocket/websocket.c

The file is compiled using

emcc tests/websocket/websocket.c

Running the resulting a.out.js with node gives the following output:

missing function: emscripten_websocket_is_supported

If the file is compiled for web with

emcc tests/websocket/websocket.c -o index.html

and served with

python -m http.server

I get the same missing function error in the browser console.
The missing function is defined in src/library_websocket.js so my guess is that this file is not included in the generated js file.

Environment Info:

OS: archlinux
emcc --version: emcc (Emscripten gcc/clang-like replacement) 1.38.25 ((unknown revision))
node --version: v11.9.0
chromium --version: Chromium 71.0.3578.98 Arch Linux

@merlinzerbe
Copy link
Author

merlinzerbe commented Feb 11, 2019

Well it turns out that I was under the (wrong?) assumption that emscripten would automatically lookup used symbols and include the corresponding .js files from src/
If I compile like

emcc tests/websocket/websocket.c --js-library src/library_websocket.js -o index.html

The functions definitions are included and the sample works in the browser. This solves my issue but leaves the question, whether there is a way to let emcc do the work of finding and including neccessary .js files located under src/?

@juj
Copy link
Collaborator

juj commented Feb 11, 2019

Traditionally we would link all JS libraries under src/ to the build, but as that set of code grew, it was becoming a bit silly - not all developers should link to everything (slows down builds and accidental symbol clashes become more probable).

Websocket support is brand new, so there the old autolinking scheme is not followed, try passing -lwebsocket.js to the build. (the --js-library option also works, but is a bit more verbose). Doc entry for this is landing, though the PR is still under review.

@merlinzerbe
Copy link
Author

okay thanks, that resolves my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants