TerenceGe / sr25519-donna

Pure C implementation of schnorrkel algorithm (sr25519)
Apache License 2.0
17 stars 5 forks source link

Can link with libsodium in same project? #19

Closed MatthewDarnell closed 3 years ago

MatthewDarnell commented 3 years ago

Hi, thanks for this project, it looks great.

I am trying to link against my project which is already using libsodium. However, I'm getting many multiple reference errors in the linker:

$ make
clang -o substrate_test src/utils/ss58.o src/utils/crypto.o src/address.o -Wall --static -fPIC -Isrc -Ilibs/deps/include -Llibs/deps -Llibs/deps/lib -lbase58 -lfastpbkdf2 -lsr25519_donna_static -lsodium -lbc-bip39 -lbc-crypto-base  -lssl -lcrypto -pthread
/mnt/c/Users/matth/Desktop/polkadot/libs/libsodium-stable/src/libsodium/sodium/core.c:188: multiple definition of `sodium_misuse'; libs/deps/lib/libsr25519_donna_static.a(core.c.o):core.c:(.text+0x20): first defined here
/usr/bin/ld: libs/deps/lib/libsodium.a(libsodium_la-ed25519_ref10.o): in function `ge25519_scalarmult':
/mnt/c/Users/matth/Desktop/polkadot/libs/libsodium-stable/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:813: multiple definition of `ge25519_scalarmult'; libs/deps/lib/libsr25519_donna_static.a(ristretto255.c.o):ristretto255.c:(.text+0xe7e0): first defined here

And it continues with some other functions that have been redefined.

TerenceGe commented 3 years ago

I'm trying to add libsodium in the example and #include , it seems can build.

Screen Shot 2021-09-04 at 5 25 18 PM Screen Shot 2021-09-04 at 5 28 35 PM

Can you list the full redefined function names so I can see if I can change that?

TerenceGe commented 3 years ago

I've changed part of the names you mentioned, can you check if the errors disappear?

MatthewDarnell commented 3 years ago

I pulled the latest and linked successfully, thank you.