Search code examples
crubyrakepaillier

Error in testing Paillier library: (.text+0x72): undefined reference to


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


Solution

  • 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.