【问题标题】:GENERAL_NAME_free error when using Aerospike from Ruby从 Ruby 使用 Aerospike 时出现 GENERAL_NAME_free 错误
【发布时间】:2017-03-28 22:54:53
【问题描述】:

我正在尝试创建一个简单的共享库libfoo.so,它使用单个函数打开与 Aerospike 服务器的连接,等待 3 秒并关闭连接。 libfoo.so 有一个函数 open_then_close(char* host, int port)

然后我想使用 FFI 从 Ruby 调用这个函数:

require 'ffi'

module Aerospike
  extend FFI::Library
  ffi_lib  "./libfoo.so", "libaerospike.so"
  attach_function :connect_then_close, [:string, :int], :int
end

puts Aerospike.connect_then_close("127.0.0.1", 3000)  

我使用 C 程序测试了foolib.so,它运行良好。但是,当我尝试运行上述代码时,出现以下错误:

Could not open library '/usr/lib/libaerospike.so': /usr/lib/libaerospike.so: undefined symbol: GENERAL_NAME_free (LoadError)

附加信息:

$ ldd /usr/lib/libaerospike.so
    linux-vdso.so.1 =>  (0x00007ffe413cb000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2ec87a3000)
    /lib64/ld-linux-x86-64.so.2 (0x00005645069a7000)

$ nm -u /usr/lib/libaerospike.so | grep GENERAL_NAME_free
       U GENERAL_NAME_free

知道有什么问题吗?

更新

$ dpkg -l | grep libgcrypt
  ii  libgcrypt11:amd64       1.5.3-2ubuntu4.3        amd64        LGPL Crypto library - runtime library

$ locate libcrypto
  /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
  /usr/lib/x86_64-linux-gnu/libcrypto.a
  /usr/lib/x86_64-linux-gnu/libcrypto.so
  /usr/lib/x86_64-linux-gnu/pkgconfig/libcrypto.pc

这就是我编译和创建libfoo.so的方式

$ gcc -Wall -c -fPIC foo.c -o foo.o -laerospike -lssl -lcrypto -lpthread -lm -lz

链接错误:

$ gcc -shared -o libfoo.so foo.o

【问题讨论】:

    标签: ruby ffi aerospike ruby-ffi


    【解决方案1】:

    看起来符号 GENERAL_NAME_free 是由 OpenSSL 的加密库根据此 man page 和此 OpenSSL forum post 定义的。所以你可能错过了 libcrypto 库。

    但我很好奇,为什么您在 Ruby 程序中使用 Aerospike C 客户端库而不是使用 Aerospike Ruby client? Ruby 客户端缺少 C 客户端中的某些特定功能吗?

    【讨论】:

    • 嗨 Jan,我发现了我的错误。上面我更新了我的帖子。问题在于我如何创建共享库。我在编译时包含了它们,但在创建共享库时忘记了它们。这是正确的方法:gcc -shared -o libfoo.so foo.o -laerospike -lssl -lcrypto -lpthread -lm -lz
    • 至于你的问题,我正在尝试从 Ruby 实现聚合。据我所知 Aerospike Ruby 客户端不支持聚合功能(map reduce 等)。您对替代解决方案有什么建议吗?
    • @fade2black,你是对的,Ruby 客户端目前不支持使用 Lua 用户定义函数的 map-reduce-style 聚合。我很高兴听到您设法解决了使用 FFI 链接到 C 客户端的工作。目前,这可能是最好的解决方案。
    • 嗨 Jan,我很好奇 does not allow using aggregation from Ruby 是什么。多线程?你能解释一下吗?
    • @fade2black,看看这个库是否满足你的需求:github.com/Minus10Degrees/AerospikeCRuby
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2014-10-04
    • 1970-01-01
    相关资源
    最近更新 更多