OK, my new .PRO file:
#-------------------------------------------------
#
# Project created by QtCreator 2010-03-31T15:03:01
#
#-------------------------------------------------
QT -= gui
TARGET = test2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/include/octave-3.2.2/
LIBS += -L"/usr/lib/octave-3.2.2/" -loctinterp
#-------------------------------------------------
#
# Project created by QtCreator 2010-03-31T15:03:01
#
#-------------------------------------------------
QT -= gui
TARGET = test2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/include/octave-3.2.2/
LIBS += -L"/usr/lib/octave-3.2.2/" -loctinterp
To copy to clipboard, switch view to plain text mode
The new code: (Not sure if the last line should be there but I guess something should be returned?)
#include <QtCore/QCoreApplication>
#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/toplev.h> /* do_octave_atexit */
int main (int argc, char *argv[])
{
const char * argvv [] = {"" /* name of program, not relevant */, "--silent"};
octave_main (2, (char **) argvv, true /* embedded */);
octave_value_list functionArguments;
functionArguments (0) = 2;
functionArguments (1) = "D. Humble";
Matrix inMatrix (2, 3);
inMatrix (0, 0) = 10;
inMatrix (0, 1) = 9;
inMatrix (0, 2) = 8;
inMatrix (1, 0) = 7;
inMatrix (1, 1) = 6;
functionArguments (2) = inMatrix;
const octave_value_list result = feval ("exampleOctaveFunction", functionArguments, 1);
std::cout << "resultScalar is " << result (0).scalar_value () << std::endl;
std::cout << "resultString is " << result (1).string_value () << std::endl;
std::cout << "resultMatrix is\n" << result (2).matrix_value ();
do_octave_atexit ();
return a.exec();
}
#include <QtCore/QCoreApplication>
#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/toplev.h> /* do_octave_atexit */
int main (int argc, char *argv[])
{
QCoreApplication a(argc, argv);
const char * argvv [] = {"" /* name of program, not relevant */, "--silent"};
octave_main (2, (char **) argvv, true /* embedded */);
octave_value_list functionArguments;
functionArguments (0) = 2;
functionArguments (1) = "D. Humble";
Matrix inMatrix (2, 3);
inMatrix (0, 0) = 10;
inMatrix (0, 1) = 9;
inMatrix (0, 2) = 8;
inMatrix (1, 0) = 7;
inMatrix (1, 1) = 6;
functionArguments (2) = inMatrix;
const octave_value_list result = feval ("exampleOctaveFunction", functionArguments, 1);
std::cout << "resultScalar is " << result (0).scalar_value () << std::endl;
std::cout << "resultString is " << result (1).string_value () << std::endl;
std::cout << "resultMatrix is\n" << result (2).matrix_value ();
do_octave_atexit ();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Here is the compiler output: (After a clean and attempt to build)
Running build steps for project test2...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/home/snurr/octaveTest/qttest/Qt-call-m/test2'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.02/qt/mkspecs/linux-g++ -I. -I../../../../qtsdk-2010.02/qt/include/QtCore -I../../../../qtsdk-2010.02/qt/include -I/usr/include/octave-3.2.2 -I. -o main.o main.cpp
g++ -Wl,-rpath,/home/snurr/qtsdk-2010.02/qt/lib -o test2 main.o -L/home/snurr/qtsdk-2010.02/qt/lib -L/usr/lib/octave-3.2.2/ -loctinterp -lQtCore -L/home/snurr/qtsdk-2010.02/qt/lib -lpthread
/usr/bin/ld: warning: liboctave.so, needed by /usr/lib/octave-3.2.2//liboctinterp.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcruft.so, needed by /usr/lib/octave-3.2.2//liboctinterp.so, not found (try using -rpath or -rpath-link)
main.o: In function `main':
/home/snurr/octaveTest/qttest/Qt-call-m/test2/main.cpp:28: undefined reference to `MatrixType::MatrixType()'
/home/snurr/octaveTest/qttest/Qt-call-m/test2/main.cpp:28: undefined reference to `MatrixType::~MatrixType()'
/home/snurr/octaveTest/qttest/Qt-call-m/test2/main.cpp:28: undefined reference to `MatrixType::~MatrixType()'
......
LOTS OF errors about undefined references here. My guess is because it cant find the .so-files?
.......
/usr/lib/octave-3.2.2//liboctinterp.so: undefined reference to `operator*(DiagMatrix const&, ComplexDiagMatrix const&)'
/usr/lib/octave-3.2.2//liboctinterp.so: undefined reference to `mx_el_ge(octave_int<unsigned int> const&, intNDArray<octave_int<long long> > const&)'
/usr/lib/octave-3.2.2//liboctinterp.so: undefined reference to `MArrayN<octave_int<unsigned char> > quotient<octave_int<unsigned char> >(MArrayN<octave_int<unsigned char> > const&, MArrayN<octave_int<unsigned char> > const&)'
collect2: ld returned 1 exit status
make: *** [test2] Error 1
Exited with code 2.
Error while building project test2
When executing build step 'Make'
Running build steps for project test2...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/home/snurr/octaveTest/qttest/Qt-call-m/test2'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.02/qt/mkspecs/linux-g++ -I. -I../../../../qtsdk-2010.02/qt/include/QtCore -I../../../../qtsdk-2010.02/qt/include -I/usr/include/octave-3.2.2 -I. -o main.o main.cpp
g++ -Wl,-rpath,/home/snurr/qtsdk-2010.02/qt/lib -o test2 main.o -L/home/snurr/qtsdk-2010.02/qt/lib -L/usr/lib/octave-3.2.2/ -loctinterp -lQtCore -L/home/snurr/qtsdk-2010.02/qt/lib -lpthread
/usr/bin/ld: warning: liboctave.so, needed by /usr/lib/octave-3.2.2//liboctinterp.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcruft.so, needed by /usr/lib/octave-3.2.2//liboctinterp.so, not found (try using -rpath or -rpath-link)
main.o: In function `main':
/home/snurr/octaveTest/qttest/Qt-call-m/test2/main.cpp:28: undefined reference to `MatrixType::MatrixType()'
/home/snurr/octaveTest/qttest/Qt-call-m/test2/main.cpp:28: undefined reference to `MatrixType::~MatrixType()'
/home/snurr/octaveTest/qttest/Qt-call-m/test2/main.cpp:28: undefined reference to `MatrixType::~MatrixType()'
......
LOTS OF errors about undefined references here. My guess is because it cant find the .so-files?
.......
/usr/lib/octave-3.2.2//liboctinterp.so: undefined reference to `operator*(DiagMatrix const&, ComplexDiagMatrix const&)'
/usr/lib/octave-3.2.2//liboctinterp.so: undefined reference to `mx_el_ge(octave_int<unsigned int> const&, intNDArray<octave_int<long long> > const&)'
/usr/lib/octave-3.2.2//liboctinterp.so: undefined reference to `MArrayN<octave_int<unsigned char> > quotient<octave_int<unsigned char> >(MArrayN<octave_int<unsigned char> > const&, MArrayN<octave_int<unsigned char> > const&)'
collect2: ld returned 1 exit status
make: *** [test2] Error 1
Exited with code 2.
Error while building project test2
When executing build step 'Make'
To copy to clipboard, switch view to plain text mode
This part I don't understand:
/usr/bin/ld: warning: liboctave.so, needed by /usr/lib/octave-3.2.2//liboctinterp.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcruft.so, needed by /usr/lib/octave-3.2.2//liboctinterp.so, not found (try using -rpath or -rpath-link)
The files are indeed located in the folders specified...??? (EDIT. Clarification: They are located in the same folder as liboctinterp.so... not in /usr/bin...)
Tried using -rpath and rpath-link aftre/instead of the - locinterp line but then g++ says "unrecognized option"
So what should I do now?
Thank you for your help! I really appreciate it!
/Tottish
Bookmarks