从C调用Octave解释器-问题编译和运行示例

问题描述

按照此答案Call GNU Octave functions in C?所示的示例,我正在尝试从C实现调用八度。

我正在Linux上的Nebeans中尝试此操作。

根据示例,我已经创建了文件calloctave.cc,calloctave.h,main.c和myfunction.m。指向链接包括到正确的位置(在我的情况下为/usr/include/octave-5.2.0/octave/和/usr/lib64/octave/5.2.0)。我选择了C ++ 11作为标准。在代码中,没有突出显示任何错误,并且似乎可以找到所需的所有内容,并且没有任何内容突出显示为丢失。

当我尝试对其进行编译时,只会出现如下一系列错误...。

cd '/home/arwel/NetBeansprojects/callOctave_new'
/bin/gmake -f Makefile CONF=Debug
"/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/arwel/NetBeansprojects/callOctave_new'
"/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/libcallOctave_new.so
gmake[2]: Entering directory `/home/arwel/NetBeansprojects/callOctave_new'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/calloctave.o.d"
g++    -c -g -I/usr/include/octave-5.2.0/octave -include /usr/include/octave-5.2.0/octave/mex.h -std=c++11 -fPIC  -MMD -MP -MF "build/Debug/GNU-Linux/calloctave.o.d" -o build/Debug/GNU-Linux/calloctave.o calloctave.cc
In file included from /usr/include/octave-5.2.0/octave/Cell.h:33:0,from /usr/include/octave-5.2.0/octave/gtk-manager.h:32,from /usr/include/octave-5.2.0/octave/interpreter.h:36,from calloctave.cc:7:
/usr/include/octave-5.2.0/octave/ov.h:52:7: error: using typedef-name ‘mxArray’ after ‘class’
 class mxArray;
       ^
In file included from <command-line>:0:0:
/usr/include/octave-5.2.0/octave/mex.h:55:14: note: ‘mxArray’ has a prevIoUs declaration here
 typedef void mxArray;
              ^
In file included from /usr/include/octave-5.2.0/octave/ov.h:62:0,from /usr/include/octave-5.2.0/octave/Cell.h:33,from calloctave.cc:7:
/usr/include/octave-5.2.0/octave/ov-base.h:57:7: error: using typedef-name ‘mxArray’ after ‘class’
 class mxArray;
       ^
In file included from <command-line>:0:0:
/usr/include/octave-5.2.0/octave/mex.h:55:14: note: ‘mxArray’ has a prevIoUs declaration here
 typedef void mxArray;
              ^
calloctave.cc: In function ‘int mexCallOctave(int,mxArray**,int,const char*)’:
calloctave.cc:26:15: error: ‘mxArray’ is not a class,namespace,or enumeration
     args(i) = mxArray::as_octave_value (argin[i]);
               ^
calloctave.cc:42:41: error: invalid use of ‘mxArray {aka void}’
       argout[i] = new mxArray (retval(i));
                                         ^
calloctave.cc: In function ‘void free_arg_list(int,mxArray**)’:
calloctave.cc:56:29: warning: deleting ‘mxArray* {aka void*}’ is undefined [enabled by default]
             delete arglist[i];
                             ^
gmake[2]: *** [build/Debug/GNU-Linux/calloctave.o] Error 1
gmake[2]: Leaving directory `/home/arwel/NetBeansprojects/callOctave_new'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/arwel/NetBeansprojects/callOctave_new'
gmake: *** [.build-impl] Error 2

BUILD Failed (exit value 2,total time: 1s)

似乎没有以某种方式理解mex界面。我对C / C ++不太了解,所以对如何进行此处很困惑。是什么原因导致这些错误,我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)