I’m trying to compile librdkafka into wasm binary. I executed following commands but on the second line, wasm-ld does not find pthread related symbols.
emcmake cmake -H. -B_cmake_build
cmake --build _cmake_build
[ 34%] Linking C executable producer.js
wasm-ld: error: ../src/librdkafka.a(rdkafka.c.o): undefined symbol: pthread_kill
wasm-ld: error: ../src/librdkafka.a(rdkafka.c.o): undefined symbol: pthread_kill
I tried several ways to inject -pthread
flag to the linker, but faced the same error. Below is several commands I have tried
emcmake cmake -H. -B_cmake_build -DCMAKE_SHARED_LINKER_FLAGS="-lpthread"
emcmake cmake -H. -B_cmake_build -DCFLAGS="-lpthread"
LDFLAGS="-pthread" cmake --build _cmake_build
1
After some research I found it’s EMCC_CFLAGS
.
EMCC_CFLAGS="-pthread" cmake --build _cmake_build
https://emscripten.org/docs/tools_reference/emcc.html#environment-variables