我在 C ++ 方面还不是很有经验,但我正在尝试将 ruby 1.8 嵌入到 qt 应用程序中,直到下载 ruby 源代码并将其放入名为“3rdparty”的项目子文件夹中并./configure
在该文件夹中运行,之后make
,现在我收到以下错误:
:-1: 错误: /home/gabriel/dev/ruby-exps/embed-ruby-first-tries/3rdparty/ruby-1.8.7-p374//libruby-static.a(dln.o): 未定义引用符号'dlclose@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libdl.so.2:-1:错误:添加符号时出错:命令行中缺少 DSO
:-1: 错误: collect2: 错误: ld 返回 1 退出状态
我的 .pro 文件是这样的:
QT += core
QT -= gui
CONFIG += c++11
TARGET = embed-ruby-first-tries
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/3rdparty/ruby-1.8.7-p374/release/ -lruby-static
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/3rdparty/ruby-1.8.7-p374/debug/ -lruby-static
else:unix: LIBS += -L$$PWD/3rdparty/ruby-1.8.7-p374/ -lruby-static
INCLUDEPATH += 3rdparty/ruby-1.8.7-p374
DEPENDPATH += 3rdparty/ruby-1.8.7-p374
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/3rdparty/ruby-1.8.7-p374/release/libruby-static.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/3rdparty/ruby-1.8.7-p374/debug/libruby-static.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/3rdparty/ruby-1.8.7-p374/release/ruby-static.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/3rdparty/ruby-1.8.7-p374/debug/ruby-static.lib
else:unix: PRE_TARGETDEPS += $$PWD/3rdparty/ruby-1.8.7-p374/libruby-static.a
我的 main.cpp 文件是这样的:
#include <QDebug>
#include <ruby.h>
int main(int argc, char *argv[])
{
ruby_init();
return ruby_cleanup(0);
}
我正在使用 qt 5.6 和 ruby 1.8.7-p374 源,如果有人告诉我如何将 ruby 嵌入 cpp 程序或至少帮助我了解发生了什么,那就太好了。