0

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

BMC
  • 591
  • 3
  • 7
  • 22
  • What is the command line you're using to compile? Seems you're missing a needed library (-l ) – Fabio Ceconello Aug 18 '14 at 22:06
  • I used g++ Test.cpp I did try -lnacl but it wont work as the library is not installed in the system path. Is it possible to link to a library within the working folder. – BMC Aug 19 '14 at 07:32
  • Solved it. Just installed the library into the system path. – BMC Aug 19 '14 at 07:39

1 Answers1

0

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

apt-get install libnacl-dev
BMC
  • 591
  • 3
  • 7
  • 22