我正在使用正在运行的 Intel MacCatalina 10.15.1
我正在尝试libsodium
使用gcc Apple clang version 11.0.0 (clang-1100.0.33.12)
我都尝试通过安装libsodium
和home-brew
手动编译(这是成功的),但是,在尝试使用时libsodium
出现此错误:
Undefined symbols for architecture x86_64:
"_crypto_generichash", referenced from:
_main in sodium-ae2fd0.o
"_sodium_init", referenced from:
_main in sodium-ae2fd0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这是基本代码,使用libsodium: stable 1.0.18 (bottled), HEAD
1 #include <sodium.h>
2
3 int main(void)
4 {
5
6 sodium_init();
7
8 #define MESSAGE ((const unsigned char *) "Arbitrary data to hash")
9 #define MESSAGE_LEN 22
10
11 unsigned char hash[crypto_generichash_BYTES];
12
13 crypto_generichash(hash, sizeof hash,
14 MESSAGE, MESSAGE_LEN,
15 NULL, 0);
16
17 return 0;
18 }
有任何想法吗?