简体   繁体   English

QtCreator(ubuntu)中的C ++八度链接错误

[英]C++ Octave in QtCreator (ubuntu) link errors

I am trying to include some octave matrix / sloving in a Qt project. 我正在尝试在Qt项目中包括一些倍频程矩阵/ sloving。 I can't figure out how to make it work. 我不知道如何使它工作。

I would like to have a Qt project, building with g++ and using QtCreator. 我想要一个Qt项目,该项目使用g ++构建并使用QtCreator。 I built Octave with g++ from source. 我从源代码使用g ++构建了Octave。 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) . 看来我可以使用Matrix了,但是一旦我使用octave_value,链接器似乎就无法工作(我的最高目标是能够对矩阵使用feval)。 Here is my main.cpp: 这是我的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...): 我的.pro(我知道这有点混乱...):

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 所以像这样我得到这样的输出:0 0 0 0 0 0 0 0 0

But if I uncomment the "octave_value valeur(a_matrix);" 但是,如果我取消注释“ octave_value valeur(a_matrix);”, line in the main.cpp I get this linking errors: main.cpp中的行我得到此链接错误:

main.o: In function main': main.cpp:(.text.startup+0xce): undefined reference to octave_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 main.o:在函数main': main.cpp:(.text.startup+0xce): undefined reference to octave_value :: octave_value(Matrix const&,MatrixType const&)的main': main.cpp:(.text.startup+0xce): undefined reference to make:离开目录`/ home / seb / TestOctave / TestOctave -build-desktop-Qt_4_8_1_in_PATH_ 系统 _Release'collect2:ld返回1退出状态

The thing is, when I build it throw : 问题是,当我构建它时抛出:

mkoctfile --link-stand-alone ./TestOctave/TestOctave/main.cpp -o testOctave 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. 总结起来,我的目标是能够在QtCreator项目中使用矩阵feval()。 Does anyone know how I could get it to work? 有谁知道我该怎么做? Thanks 谢谢

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. 我已经建立了octave 3.6.4,但是遇到了错误,因此没有创建octinterp.so ...我最终使用了安装在gnu octave软件包中的库。

so here is the working code: (the main.cpp stays pretty much the same): 所以这是工作代码:( main.cpp几乎保持不变):

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... 总结起来,我想念liboctinterp.so和libcruft.so希望对您有所帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM