user2964630
user2964630

Reputation: 73

C++ Octave in QtCreator (ubuntu) link errors

I am trying to include some octave matrix / sloving in a Qt project. I can't figure out how to make it work.

I would like to have a Qt project, building with g++ and using QtCreator. I built Octave with g++ from source. It seems I can get a Matrix to work but as soon as I use a octave_value the linker can't seem to work (my utlimate goal is to be able to use feval with matrices) . Here is my main.cpp:

#include <iostream>
#include <oct.h>
#include <octave.h>
#include <parse.h>

int
main (void)
{
    Matrix a_matrix = Matrix (3, 3);

    std::cout << a_matrix;
    //octave_value valeur(a_matrix);

    return 0;
}

my .pro (I know it's a little messy...):

QT       += core gui

TARGET = TestOctave
TEMPLATE = app

INCLUDEPATH += $$PWD/../../octave-3.6.4
INCLUDEPATH += $$PWD/../../octave-3.6.4/src
INCLUDEPATH += $$PWD/../../octave-3.6.4/liboctave
INCLUDEPATH += $$PWD/../../octave-3.6.4/libcruft/misc/
INCLUDEPATH += $$PWD/../../octave-3.6.4/liboctave/.libs
LIBS += -L$$PWD/../../octave-3.6.4/liboctave/.libs/ -loctave

SOURCES += main.cpp

So like this I get an output like this : 0 0 0 0 0 0 0 0 0

But if I uncomment the "octave_value valeur(a_matrix);" line in the main.cpp I get this linking errors:

main.o: In function main': main.cpp:(.text.startup+0xce): undefined reference tooctave_value::octave_value(Matrix const&, MatrixType const&)' make: Leaving directory `/home/seb/TestOctave/TestOctave-build-desktop-Qt_4_8_1_in_PATH_System_Release' collect2: ld returned 1 exit status

The thing is, when I build it throw :

mkoctfile --link-stand-alone ./TestOctave/TestOctave/main.cpp -o testOctave

And it builds, links and executes properly.

To sum up, my goal is to be able to use matrices, feval() in a QtCreator project. Does anyone know how I could get it to work? Thanks

Upvotes: 1

Views: 812

Answers (1)

user2964630
user2964630

Reputation: 73

Ok, I answered my question so here is what I found might help someone..

I had built octave 3.6.4 but had had errors hence not creating octinterp.so... I ended up using the libs that where installed in the package gnu octave.

so here is the working code: (the main.cpp stays pretty much the same):

QT       += core gui

TARGET = TestOctave
TEMPLATE = app

INCLUDEPATH += /usr/include/octave-3.2.4/
INCLUDEPATH += $$PWD/../../../../usr/lib/octave-3.2.4

DEPENDPATH += $$PWD/../../../../usr/lib/octave-3.2.4

unix:!macx:!symbian: LIBS += -L$$PWD/../../../../usr/lib/octave-3.2.4/ -loctave
unix:!macx:!symbian: LIBS += -L$$PWD/../../../../usr/lib/octave-3.2.4/ -loctinterp
unix:!macx:!symbian: LIBS += -L$$PWD/../../../../usr/lib/octave-3.2.4/ -lcruft


SOURCES += main.cpp

HEADERS  +=

FORMS    += mainwindow.ui

OTHER_FILES += \
    ../../../../usr/lib/octave-3.2.4/liboctinterp.so.3.2.4

To sum up, I was missing liboctinterp.so and libcruft.so Hope it helps someone...

Upvotes: 1

Related Questions