【问题标题】:NaCl XSalso20 C code not compilingNaCl XSalso20 C 代码未编译
【发布时间】:2014-08-18 19:29:10
【问题描述】:

我只是在尝试 NaCl 网站上的 Xsalsa20 代码。我无法编译它。

  #include "build/BlackDragon/include/x86/crypto_stream.h"
#include<stdio.h>

int main(){
//const unsigned char m[crypto_stream_xsalsa20;
const unsigned char k[crypto_stream_xsalsa20_KEYBYTES] = "1234567890123456789012345678901";
const unsigned char n[crypto_stream_xsalsa20_NONCEBYTES] = "12345678901234567890123";
unsigned char c[51];
unsigned long long len;
len = 50;
crypto_stream_xsalsa20(c,len,n,k);

//printf("%s",m);
return 0;
}

当我尝试使用 GCC 编译它时,我收到以下错误消息。

/tmp/ccNaI8Z1.o: In function `main':
Test.cpp:(.text+0xbc): undefined reference to `crypto_stream_xsalsa20_ref'
/tmp/ccNaI8Z1.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
collect2:error: ld returned 1 exit status

谁能帮我解决这个问题。

PS:这段代码在我编译 NaCl 的 NaCl 文件夹中

【问题讨论】:

  • 你用来编译的命令行是什么?似乎您缺少所需的库 (-l )
  • 我使用了 g++ Test.cpp 我试过 -lnacl 但它不会工作,因为库没有安装在系统路径中。是否可以链接到工作文件夹中的库。
  • 解决了。刚刚将库安装到系统路径中。

标签: c gcc ld nacl-cryptography


【解决方案1】:

我通过将库安装到系统路径中解决了这个问题。 为方便起见,您可以使用

apt-get install libnacl-dev

【讨论】:

    猜你喜欢
    • 2016-03-16
    • 1970-01-01
    • 2011-04-01
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 1970-01-01
    相关资源
    最近更新 更多