八度 header 缺失

Octave header missing

我正在使用 ubuntu 16.04 并且我通过软件中心安装了 gnu octave (4.0.2)。我可以通过 shell 运行 八度,但如果我想在 C++ 代码中使用它,我不会落后于如何开始。它在开头直接中断,缺少八度 header:

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

导致

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

我知道它在 /usr/include/octave-4.0.2/octave/。我如何让我的代码知道这一点? 非常感谢您!

您需要将正确的标志传递给您的编译器。您可以使用 octave-config 程序像这样找到它们:

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

但是,使用 mkoctfile 更容易,这就是手册部分关于 Stand-alone Programs 的解释。像这样:

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