Build a lib with emscripten target

I've been trying to build a library, and one of my targets is emscripten, the library uses tokio-tungestinite so I can't target wasm32-unknown-unknown

If I run cargo build --target wasm32-unknown-emscripten I get

wasm-ld: error: /opt/homebrew/Cellar/emscripten/3.1.44/libexec/cache/sysroot/lib/wasm32-emscripten/libstandalonewasm.a(__main_void.o): undefined symbol: main

For testing, I'm building the sample project we get after creating a rust lib cargo new --lib

Can someone point me in the proper direction or provide a minimal working example?

I've installed emscripten from brew.

If your goal is to run this in a browser, it won't be useful to compile tungstenite anyway — it's a WS implementation, but in browsers, raw networking is not available and you have to use their own WS API.

I'm creating a library, which should not have an entry point :confused:

Ah, but isn't the idea behind emscripten to emulate libc so the network calls pass through emscripten and then translate to the browser WS API?

tungstenite needs access to TCP sockets on top of which it can implement WebSockets. Browsers don't give you sockets, only higher-level protocols that are implemented on top of TCP or UDP (HTTP, WebSocket, WebRTC, FTP, ...) so it is impossible to create TCP sockets out of that.

You have to use the existing WS implementation the browser gives you; one compiled into your code is useless.