I'm not very experienced in C ++ yet but I'm trying to embed the ruby 1.8 in a qt application, and what I did until it was to download the ruby source code and put it in a project subfolder called '3rdparty' and run ./configure inside that folder and after make and now I'm getting the followings errors:
:-1: error: /home/gabriel/dev/ruby-exps/embed-ruby-first-tries/3rdparty/ruby-1.8.7-p374//libruby-static.a(dln.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libdl.so.2:-1: error: error adding symbols: DSO missing from command line
:-1: error: collect2: error: ld returned 1 exit status
My .pro file is like this:
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
And my main.cpp file is like this:
#include <QDebug>
#include <ruby.h>
int main(int argc, char *argv[])
{
ruby_init();
return ruby_cleanup(0);
}
I'm using qt 5.6 and ruby 1.8.7-p374 source, it'll be great if anyone tell me how I do to embed the ruby on a cpp program or at least help me understand what's going on.
This is usually a sign that you are missing some library from the linking phase. The error message is not very descriptive though.
In this case
undefined reference to symbol 'dlclose'gives a hint of which library is missing. In this casedlclosehappens to be inlibdl. So adding:...to linker options (
LIBS +=) should get you closer to the solution.