NaCl XSalso20 C code not compiling

159 Views Asked by At

I was just trying out the Xsalsa20 code from NaCl website. I am unable to compile it.

  #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;
}

When I try to compile this with GCC I am getting the following error message.

/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

Could someone please help me trouble shoot this.

PS: This code is within the NaCl folder where I compiled NaCl

1

There are 1 best solutions below

0
On

I solved this by installing the library into the system path. For easy you can use

apt-get install libnacl-dev