Duplicate symbol: blake2b when linking with libsodium
-
Hi,
I have developed a library that use "QbyteArray" from Qt and also libsodium functions like "crypto_sign_seed_keypair".
When compiling to wasm the library builds.
But when compiling an executable that depends on the library and call functions that will call "crypto_sign_seed_keypair"(of libsodium) the linker complains about duplicate symbols.
Specifically, when doing make step:make [ 16%] Building CXX object _deps/ed25519-build/CMakeFiles/ed25519.dir/ed25519.cpp.o [ 33%] Linking CXX static library libed25519.a [ 33%] Built target ed25519 [ 50%] Building CXX object CMakeFiles/qed25519.dir/qed25519.cpp.o [ 66%] Linking CXX static library libqed25519.a [ 66%] Built target qed25519 [ 83%] Building CXX object tests/CMakeFiles/test1.dir/test1.cpp.o [100%] Linking CXX executable test1.js wasm-ld: error: duplicate symbol: blake2b_init_param >>> defined in /home/user/Qt/6.3.1/wasm_32/lib/libQt6Core.a(qcryptographichash.cpp.o) >>> defined in /home/user/WASM/LATEST/libsodium-stable/libsodium-js/lib/libsodium.a(libsodium_la-blake2b-ref.o) wasm-ld: error: duplicate symbol: blake2b_init >>> defined in /home/user/Qt/6.3.1/wasm_32/lib/libQt6Core.a(qcryptographichash.cpp.o) >>> defined in /home/user/WASM/LATEST/libsodium-stable/libsodium-js/lib/libsodium.a(libsodium_la-blake2b-ref.o) wasm-ld: error: duplicate symbol: blake2b_init_key >>> defined in /home/user/Qt/6.3.1/wasm_32/lib/libQt6Core.a(qcryptographichash.cpp.o) >>> defined in /home/user/WASM/LATEST/libsodium-stable/libsodium-js/lib/libsodium.a(libsodium_la-blake2b-ref.o) wasm-ld: error: duplicate symbol: blake2b_final >>> defined in /home/user/Qt/6.3.1/wasm_32/lib/libQt6Core.a(qcryptographichash.cpp.o) >>> defined in /home/user/WASM/LATEST/libsodium-stable/libsodium-js/lib/libsodium.a(libsodium_la-blake2b-ref.o) wasm-ld: error: duplicate symbol: blake2b >>> defined in /home/user/Qt/6.3.1/wasm_32/lib/libQt6Core.a(qcryptographichash.cpp.o) >>> defined in /home/user/WASM/LATEST/libsodium-stable/libsodium-js/lib/libsodium.a(libsodium_la-blake2b-ref.o)
It seems that both static libraries qt6Core and libsodium use the same blake2b source codes.
I need both libraries(qt6Core and libsodium) in my library.
But I do not need to link to qcryptographichash.cpp.o object.
How can i neglect this object when linking using emscripten?
I use cmake.I will much appreciate if some one advise me on how to resolve this.
Thanks for your time. -
I noticed that ed25519 do not need blake2b. A temporal solution was to remove the object "libsodium_la-blake2b-ref.o" from libsodium.a by using
ar dv libsodium.a libsodium_la-blake2b-ref.o
I can not remove "qcryptographichash.cpp.o" from libQt6Core.a because I use that on other libraries.