jedisct1 / libsodium

A modern, portable, easy to use crypto library.
https://libsodium.org
Other
12.26k stars 1.74k forks source link

Cross-compiling arm-none-eabi error #779

Closed zhang-wenchao closed 5 years ago

zhang-wenchao commented 5 years ago
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-generichash_blake2b.o): In function `crypto_generichash_blake2b_final':
generichash_blake2b.c:(.text+0x1b4): undefined reference to `__assert_func'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-blake2b-ref.o): In function `crypto_generichash_blake2b__init_key':
blake2b-ref.c:(.text+0x454): undefined reference to `__memcpy_chk'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-blake2b-ref.o): In function `crypto_generichash_blake2b__init_key_salt_personal':
blake2b-ref.c:(.text+0x578): undefined reference to `__memcpy_chk'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-blake2b-ref.o): In function `crypto_generichash_blake2b__final':
blake2b-ref.c:(.text+0x6a8): undefined reference to `__assert_func'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-core.o): In function `sodium_misuse':
core.c:(.text+0x84): undefined reference to `abort'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_memzero':
utils.c:(.text+0x8): undefined reference to `explicit_bzero'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_mlock':
utils.c:(.text+0x20c): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_munlock':
utils.c:(.text+0x22c): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_allocarray':
utils.c:(.text+0x288): undefined reference to `__aeabi_uidiv'
utils.c:(.text+0x2a0): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_mprotect_noaccess':
utils.c:(.text+0x2cc): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_mprotect_readonly':
utils.c:(.text+0x2e8): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_mprotect_readwrite':
utils.c:(.text+0x304): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-utils.o): In function `sodium_pad':
utils.c:(.text+0x350): undefined reference to `__aeabi_uidivmod'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-argon2-core.o): In function `initialize':
argon2-core.c:(.text+0x754): undefined reference to `__aeabi_uidiv'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-argon2-fill-block-ref.o): In function `fill_segment_ref':
argon2-fill-block-ref.c:(.text+0x4144): undefined reference to `__aeabi_uidivmod'
argon2-fill-block-ref.c:(.text+0x4194): undefined reference to `__aeabi_uidivmod'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-randombytes.o): In function `randombytes_uniform':
randombytes.c:(.text+0x104): undefined reference to `__aeabi_uidivmod'
randombytes.c:(.text+0x11c): undefined reference to `__aeabi_uidivmod'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-randombytes.o): In function `randombytes':
randombytes.c:(.text+0x210): undefined reference to `__assert_func'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-randombytes_sysrandom.o): In function `randombytes_sysrandom_close':
randombytes_sysrandom.c:(.text+0x34): undefined reference to `close'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-randombytes_sysrandom.o): In function `randombytes_sysrandom_stir':
randombytes_sysrandom.c:(.text+0x70): undefined reference to `__errno'
randombytes_sysrandom.c:(.text+0x8c): undefined reference to `open'
randombytes_sysrandom.c:(.text+0xa0): undefined reference to `fstat'
randombytes_sysrandom.c:(.text+0xc4): undefined reference to `fcntl'
randombytes_sysrandom.c:(.text+0xdc): undefined reference to `fcntl'
randombytes_sysrandom.c:(.text+0xe4): undefined reference to `__errno'
randombytes_sysrandom.c:(.text+0x104): undefined reference to `close'
randombytes_sysrandom.c:(.text+0x110): undefined reference to `__errno'
randombytes_sysrandom.c:(.text+0x12c): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-randombytes_sysrandom.o): In function `randombytes_sysrandom_buf':
randombytes_sysrandom.c:(.text+0x1b4): undefined reference to `__assert_func'
randombytes_sysrandom.c:(.text+0x1f4): undefined reference to `read'
randombytes_sysrandom.c:(.text+0x200): undefined reference to `__errno'
randombytes_sysrandom.c:(.text+0x210): undefined reference to `__errno'
/Users/wenchao/Downloads/libsodium-1.0.16/link/lib/libsodium.a(libsodium_la-ed25519_ref10.o): In function `ge25519_from_uniform':
ed25519_ref10.c:(.text+0xa6c0): undefined reference to `abort'
collect2: error: ld returned 1 exit status
jedisct1 commented 5 years ago

Did you read the documentation?

zhang-wenchao commented 5 years ago
Cross-compiling
Cross-compilation is fully supported. This is an example of cross-compiling to ARM using the GNU tools for ARM embedded processors:

export PATH=/path/to/gcc-arm-none-eabi/bin:$PATH
export LDFLAGS='--specs=nosys.specs'
export CFLAGS='-Os'
./configure --host=arm-none-eabi --prefix=/install/path
sudo make install
make check can also build the test apps, but these have to be run on the native platform.

Note: --specs=nosys.specs is only required for the ARM compilation toolchain.
zhang-wenchao commented 5 years ago

@jedisct1

zhang-wenchao commented 5 years ago

macOS 10.14 gcc-arm-none-eabi-7-2018-q2-update-mac

zhang-wenchao commented 5 years ago

I have tried it many times.

jedisct1 commented 5 years ago

There must be something wrong with your installation.

I just tried on macOS, using gcc-arm-none-eabi-7-2018-q2-update-mac downloaded from the ARM website, followed these exact instructions and it worked out of the box.

Try without sudo maybe?

jedisct1 commented 5 years ago

On small devices, you should consider libhydrogen instead of libsodium.