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

wasm-ld: error: unable to find library -lstdc++ #276

Closed
dstaley opened this issue Dec 31, 2022 · 2 comments
Closed

wasm-ld: error: unable to find library -lstdc++ #276

dstaley opened this issue Dec 31, 2022 · 2 comments

Comments

@dstaley
Copy link

dstaley commented Dec 31, 2022

I'm attempting to compile a non-trivial application written in Rust and using a large number of external libraries to WASM, and am encountering the following error:

wasm-ld: error: unable to find library -lstdc++

Looking at the log, stdc++ is only present after a file that originates from the wasm32-wasi toolchain:

"/usr/local/rustup/toolchains/1.66.0-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libcompiler_builtins-d747d107c1fad665.rlib" "-l" "stdc++" "-l" "c"

I'll be the first to admit this is probably a trivial error, but after a decent chunk of searching I wasn't able to find anyone else experiencing this specific issue in combination with Rust and WASI.

I'm using the following environment variables:

WASI_SYSROOT=/usr/wasi-sdk-16.0/share/wasi-sysroot
CC_wasm32_wasi=/usr/wasi-sdk-16.0/bin/clang
CARGO_TARGET_WASM32_WASI_LINKER=/usr/wasi-sdk-16.0/bin/clang
@sbc100
Copy link
Member

sbc100 commented Dec 31, 2022

I don't know that anyone has posrted libstc++ (the GNU C++ library) to wasm. For wasi-sdk you want to link with -lc++ (the llvm C++ library) instead.

@dstaley
Copy link
Author

dstaley commented Jan 1, 2023

Ah thank you! This pushed me to investigate a bit more, and I discovered that one of my deps was manually invoking cc to determine the availability of libstdc++, which was present on my system since I was using Linux. Gonna close this since it appears to be an issue with my specific dependency versus wasi-sdk.

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