0

I am new to C++, and I have troubles to get going. I want to re-implement a code, written in GNU Octave, using C++. I would, however, still want to use some GNU Octave functionality in that C++ code.

I have installed GNU Octave 4.0.0 on Ubuntu 14.04 LTS. My problem is that I can not even compile, since the 'octave/oct.h' is missing?

A simple code

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

using namespace std;

int main ()
{

  Complex number = Complex(0, 1);
  cout << number;

}

when compiled with g++ (4.8.4) produces:

"fatal error: octave/oct.h: Aucun fichier ou dossier de ce type #include compilation terminated.".

Thanks for your help.

1

1 Answer 1

2

Working with GNU Octave's own minimal example, you should be able to compile and run it without problems using

$ mkoctfile --link-stand-alone standalone.cc -o standalone
$ ./standalone
Hello Octave world!
 11 12
 21 22

In order to be able to use mkoctfile, you need to install the liboctave-dev Install liboctave-dev package

$ sudo apt-get install liboctave-dev
4
  • Okay, then I guess you should actually use the <> notation to include that octave header file. The difference between "" and <> notation is that the first one searches for the files relative to your current location and the second one searches in a number of paths that are predetermined by your compiler e.g. where it expects standard library headers to be. More about that here: stackoverflow.com/questions/21593/… In that sense: you should probably rather go with the example they give you.
    – hopfi
    Jan 15, 2016 at 15:13
  • Hey Anders, I tried to compile it myself now and edited my original answer. If that works for you, too, then please mark the answer as a solution.
    – hopfi
    Jan 15, 2016 at 15:25
  • Hey steeldriver, thanks for the remark. I am quite new to this, so I thought I should leave my first answer as kind of a "legacy" so that people reading the comments beneath the answer actually understand what those are referring to. Do you still think the first answer should be deleted? As I said, I'm not sure about the best practices.
    – hopfi
    Jan 15, 2016 at 15:37
  • Is there a liboctave-dev for windows?
    – Naveen
    Sep 22, 2022 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .