简体   繁体   English

Octave:编译 C++ 文件时找不到 mkoctfile

[英]Octave: mkoctfile not found when compiling a C++ file

I am trying to use Octave functions in C++.我正在尝试在 C++ 中使用 Octave 函数。 I install Octave-3.8.0 on Mac OS X 10.9.3 and follow the standalone program example on Octave website ,我在 Mac OS X 10.9.3 上安装 Octave-3.8.0 并遵循 Octave 网站上的独立程序示例,

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

int
main (void)
{
std::cout << "Hello Octave world!\n";

int n = 2;
Matrix a_matrix = Matrix (n, n);

for (octave_idx_type i = 0; i < n; i++)
  for (octave_idx_type j = 0; j < n; j++)
    a_matrix(i,j) = (i + 1) * 10 + (j + 1);

 std::cout << a_matrix;

return 0;
}

Then I type然后我输入

      $ mkoctfile --link-stand-alone main.cpp -o standalone

But it shows mkoctfile: command not found.但它显示 mkoctfile: command not found。 What is the problem?问题是什么?

I also tried to compile the C++ file with g++我也尝试用 g++ 编译 C++ 文件

     $ g++ -I /usr/local/octave/3.8.0/include/octave-3.8.0 main.cpp

but it shows 2 errors as follows.但它显示 2 个错误如下。 1) 'config.h' file not found with include; 1) 'config.h' 文件未在 include 中找到; use "quotes" instead.改用“引号”。 2) fatal error: 'hdft.h' file not found. 2) 致命错误:找不到“hdft.h”文件。

Please help me!请帮我!

It may be that octave is not registered in your system properly, judging by the shell response.根据 shell 响应判断,可能是 Octave 未在您的系统中正确注册。

Try invoking the command from inside the octave interpreter.尝试从八度解释器内部调用命令。

Not sure about on MacOS, but on Linux, mkoctfile is not bundled within the default Octave distribution.不确定在 MacOS 上,但在 Linux 上, mkoctfile未捆绑在默认的 Octave 发行版中。 Instead, it requires a supplementary package, liboctave-dev , that has to be installed in addition to Octave itself.相反,它需要一个补充包liboctave-dev ,除了 Octave 本身之外还必须安装它。

This is not documented in the Octave web tutorial.这在 Octave 网络教程中没有记录。

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

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