【问题标题】:Error in testing Paillier library: (.text+0x72): undefined reference to测试 Paillier 库时出错:(.text+0x72): undefined reference to
【发布时间】:2017-05-20 23:19:40
【问题描述】:

我正在尝试使用这个 Paillier libray http://acsc.cs.utexas.edu/libpaillier/,它只是我尝试为 Mysql 服务器制作的一些 UDF 的一部分

这是我的 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

但是,我收到了这个错误:

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':

请问有谁知道问题出在哪里?

Ps:exec_file 是一个 C 文件,我在其中包含 paillier.h

【问题讨论】:

    标签: c ruby rake paillier


    【解决方案1】:

    您的 gcc 调用中的参数顺序可能有问题。 库应该写在源文件和输出文件之后:

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

    另见this question

    【讨论】:

    • thanx 对我来说非常有效,我已经更改了源文件和 lib 的顺序,例如 gcc #{config[:exec_file]}.c -o #{config[:exec_file]} - lgmp -lpaillier -L/usr/local/lib/ -I/usr/local/include/ ,显然将 -l 放在源文件之前是一种不好的做法,这可能会导致链接时未定义的引用。
    • 是的,很难直观地理解 gcc 如何需要它的参数。很高兴现在听到它的链接。
    • 是的,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 2011-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    相关资源
    最近更新 更多