C++ WebAssembly 模块 libsodium 集成

问题描述 投票:0回答:1

我是 WebAssembly 世界的新手。

我刚刚开始尝试。

我正在尝试编写自己的 C++ 模块,该模块使用一些第三方库。

例如,我正在尝试实现一个利用

libsodium
库的 C++ WebAssembly 模块。 所以,我添加到我的代码中:

#include <sodium.h>

由于我的本地环境中没有libsodium(我使用的是Mac OS),因此我使用brew libsodium安装了它。

所以,我尝试使用以下命令编译我的模块:

emcc -o example.html module.cpp -s WASM=1 -L/usr/local/Cellar/libsodium/1.0.19/lib -lsodium -I/usr/local/Cellar/libsodium/1.0.19/include

但我不断收到警告和错误:

wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aead_aegis128l.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aegis128l_soft.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aead_aegis256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aegis256_soft.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aead_aes256gcm.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aead_chacha20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-aead_xchacha20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_auth.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-auth_hmacsha256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-auth_hmacsha512.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-auth_hmacsha512256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_box.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_box_easy.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_box_seal.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-box_curve25519xsalsa20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-ed25519_ref10.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core_hchacha20.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core_hsalsa20_ref2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core_hsalsa20.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core_salsa_ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-softaes.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_generichash.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-generichash_blake2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-blake2b-compress-ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-blake2b-ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-generichash_blake2b.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_hash.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-hash_sha256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-hash_sha256_cp.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-hash_sha512.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-hash_sha512_cp.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-kdf_blake2b.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_kdf.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-kdf_hkdf_sha256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-kdf_hkdf_sha512.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_kx.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_onetimeauth.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-onetimeauth_poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-poly1305_donna.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-argon2-core.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-argon2-encoding.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-argon2-fill-block-ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-argon2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-blake2b-long.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-pwhash_argon2i.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-pwhash_argon2id.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_pwhash.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_scalarmult.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-x25519_ref10.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-scalarmult_curve25519.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_secretbox.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_secretbox_easy.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-secretbox_xsalsa20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-secretstream_xchacha20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_shorthash.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-shorthash_siphash24.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-shorthash_siphash24_ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_sign.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-sign_ed25519.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-keypair.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-open.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-sign.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_chacha20.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-chacha20_ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_stream.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_salsa20.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_xsalsa20.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-verify.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-randombytes.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-codecs.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-runtime.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-utils.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-version.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-salsa20_xmm6-asm.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-salsa20_xmm6.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-curve25519_sandy2x.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-fe51_invert.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-fe_frombytes_sandy2x.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-sandy2x.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-box_curve25519xchacha20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-box_seal_curve25519xchacha20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core_ed25519.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-core_ristretto255.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-crypto_scrypt-common.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-scrypt_platform.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-pbkdf2-sha256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-pwhash_scryptsalsa208sha256.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-pwhash_scryptsalsa208sha256_nosse.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-scalarmult_ed25519_ref10.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-scalarmult_ristretto255_ref10.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-secretbox_xchacha20poly1305.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-shorthash_siphashx24.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-shorthash_siphashx24_ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-obsolete.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_salsa2012_ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_salsa2012.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_salsa208_ref.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_salsa208.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-stream_xchacha20.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsodium_la-randombytes_sysrandom.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libaesni_la-aead_aes256gcm_aesni.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libaesni_la-aegis128l_aesni.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libaesni_la-aegis256_aesni.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libarmcrypto_la-aead_aes256gcm_armcrypto.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libarmcrypto_la-aegis128l_armcrypto.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libarmcrypto_la-aegis256_armcrypto.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsse2_la-poly1305_sse2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsse2_la-pwhash_scryptsalsa208sha256_sse.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libssse3_la-argon2-fill-block-ssse3.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libssse3_la-blake2b-compress-ssse3.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libssse3_la-chacha20_dolbeau-ssse3.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libsse41_la-blake2b-compress-sse41.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libavx2_la-argon2-fill-block-avx2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libavx2_la-blake2b-compress-avx2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libavx2_la-chacha20_dolbeau-avx2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libavx2_la-salsa20_xmm6int-avx2.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'libavx512f_la-argon2-fill-block-avx512f.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/Cellar/libsodium/1.0.19/lib/libsodium.a: archive member 'librdrand_la-randombytes_internal_random.o' is neither Wasm object file nor LLVM bitcode

wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _embind_register_class
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _embind_register_class_class_function
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _embind_register_class_class_function
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _embind_register_bindings
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _emval_get_global
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _emval_get_property
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _emval_decref
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _emval_as
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _emval_run_destructors
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: sodium_init
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: randombytes_buf
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: crypto_aead_aes256gcm_encrypt
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: sodium_init
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: crypto_aead_aes256gcm_decrypt
wasm-ld: error: /var/folders/bn/gbn9_dvx3vq3h4k_k2wm0k4w0000gp/T/emscripten_temp_qg8ss4u4/module_0.o: undefined symbol: _emval_new_cstring 

我不明白我是否遵循了正确的方法,或者我是否在概念上误解了某些内容。

WebAssembly 是否需要编译外部库?

如果是这样,我该如何编译libsodium?从文档(https://doc.libsodium.org/)来看,它似乎与 WebAssembly 兼容。

c++ webassembly emscripten libsodium
1个回答
0
投票

Homebrew 安装的库仅适用于 macOS 和您的 CPU 型号。

WebAssembly 有自己的约定,因此所有内容都必须为其重新编译。

下载libsodium源代码:

git clone --branch=stable https://github.com/jedisct1/libsodium

运行 Emscripten 的构建脚本:

cd libsodium
./dist-build/emscripten.sh --standard

过了一会儿,

libsodium-js
目录包含包含文件和为WebAssembly编译的
libsodium.a
文件。

© www.soinside.com 2019 - 2024. All rights reserved.