-1

I am trying to use this Paillier libray http://acsc.cs.utexas.edu/libpaillier/ , it will be just a part of some UDF that i m trying to make for Mysql server

This a part from my Rakefile:

task :compile do
  puts 'Compiling the encryption / decryption program.'
  system("gcc -L/usr/local/lib/ -I/usr/local/include/ -lgmp -lpaillier #{config[:exec_file]}.c -o #{config[:exec_file]}")
end

However, i m geeting this error:

cipher.c:(.text+0x72): undefined reference to `paillier_get_rand_devurandom'
cipher.c:(.text+0x79): undefined reference to `paillier_keygen'
cipher.c:(.text+0x85): undefined reference to `paillier_pubkey_to_hex'
cipher.c:(.text+0x95): undefined reference to `paillier_prvkey_to_hex'
cipher.c:(.text+0xe3): undefined reference to `paillier_freepubkey'
cipher.c:(.text+0xef): undefined reference to `paillier_freeprvkey'
/tmp/ccMPIY0I.o: In function `getKey':

So please, any one knows where the problem is?

Ps: exec_file is a the C file where I am including paillier.h

Gerry
  • 10,337
  • 3
  • 31
  • 40
Bochra
  • 13
  • 6

1 Answers1

0

You may have a problem in the order of arguments in your gcc call. The libraries should be written after the source file and output file:

gcc -L/usr/local/lib/ -I/usr/local/include/ #{config[:exec_file]}.c -o #{config[:exec_file]} -lgmp -lpaillier

See also this question.

Community
  • 1
  • 1
nucleon
  • 1,128
  • 1
  • 6
  • 19
  • thanx that worked perfectly for me i ve changed the order of the source file and the lib like this gcc #{config[:exec_file]}.c -o #{config[:exec_file]} -lgmp -lpaillier -L/usr/local/lib/ -I/usr/local/include/ , apparently putting -l before source files is a bad practice, that may lead to undefined references when linking. – Bochra May 21 '17 at 08:39
  • Yeah, it's hard to develop an intuition for how gcc requires its arguments. Nice to hear it links now. – nucleon May 21 '17 at 08:45
  • yup, thanx for that – Bochra May 21 '17 at 17:05