0
votes

I'm using ubuntu 16.04 and I installed gnu octave (4.0.2) through the software center. I can run octave via the shell but I do not get behind how to start if I want to use it in a c++ code. It breaks directly at the beginning by missing the octave header:

#include <iostream>
#include <octave/octave.h>

leads to

/home/analysis/Filter/Filter.cxx:2:10: fatal error: 'octave/octave.h' file not found
#include <octave/octave.h>

I know it is in /usr/include/octave-4.0.2/octave/. How do I get my code to know this ? Thank you very much in advance!

1
What compiler are you using? I assume one of the ways is giving the compiler the correct flags for inclusions/libs - Ander Biguri
@AnderBiguri At first thanks your response! At the moment I try it through the ACLiC-compiler (Cern ROOT). - Ben
Oh someone from CERN! ACLiC doesnt seem to be a compiler if I am not wrong, it is a software that will find you a compiler installed at CERN and use that one. As a side note: why Octave? Octave is.... lets say, unreliable often. If you want to go with a free version of something similar to MATLAB, python seems to be a way better option. - Ander Biguri
I'm not really from CERN though some of my colleques are :) I want to test several tools and I do not want to spend weeks to hard code each tool, so that's why I would like to use octave. But actually I'm not doing anything else than to figure out how to run/call it in my code for a whole day now.. - Ben
Then I think the best approach for you is to get a compiler and try to call it yourself with whatever Octave needs. In linux, compiling C++ with octave, its not going to be pretty, especially if you are not use to fiddleing with this type of stuff. If you use an specific compiler, with specific set up, then you may ask the question and get answered, but if the compiler is not known, then only someone running ACLiC will be able to help - Ander Biguri

1 Answers

1
votes

You need to pass the right flags to your compiler. You can use the octave-config program to find them like so:

$ octave-config-4.2.1 -p OCTINCLUDEDIR
/usr/local/include/octave-4.2.1/octave

However, it's easier to use mkoctfile which is what is explained in the manual section about Stand-alone Programs. Like so:

mkoctfile --link-stand-alone standalone.cc -o standalone