简体   繁体   English

使用Octave库的C ++程序

[英]C++ programs using Octave libraries

I try to use in my c++ project libraries from Octave. 我尝试在Octave的c ++项目库中使用。 Unfortunately, I am not able to build program. 不幸的是,我无法构建程序。 I use Windows 7 64 bit, Octave3.6.4_gcc4.6.2 and gcc 4.6.2. 我使用Windows 7 64位,Octave3.6.4_gcc4.6.2和gcc 4.6.2。

My steps: 我的步骤:

  1. Downloaded Octave3.6.4_gcc4.6.2.exe ( http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.4%20for%20Windows%20MinGW%20installer/Octave3.6.4_gcc4.6.2_20130408.7z/download ) 下载了Octave3.6.4_gcc4.6.2.exe( http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.4%20for%20Windows%20MinGW%20installer/Octave3.6.4_gcc4.6.2 _20130408.7z /下载

Which I installed in C:\\Octave. 我安装在C:\\ Octave中。 I have added the address of the bin folder of octave to the environmental variable PATH. 我已将octave的bin文件夹的地址添加到环境变量PATH中。

  1. Downloaded mingw32-gcc-4.6.2-release-c,c++,fortran-sjlj-FINAL.7z and installed in C drive. 下载mingw32-gcc-4.6.2-release-c,c ++,fortran-sjlj-FINAL.7z并安装在C驱动器中。 I have added the address of the bin folder of mingw to the environmental variable PATH. 我已将mingw的bin文件夹的地址添加到环境变量PATH中。

  2. Tried to compile simple example main.cpp (or example from http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs ) 试图编译简单的示例main.cpp(或来自http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs的示例)

.

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

using namespace std;

int main() {

  return 0;
}
  1. I used makefile: 我使用了makefile:

.

OCTAVE_INCLUDE=C:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4

all: test

clean:
    -rm test.o test

test: test.o
    mkoctfile --link-stand-alone -o test test.o

test.o: main.cpp
    g++ -c -I$(OCTAVE_INCLUDE) -I$(OCTAVE_INCLUDE)octave -o test.o main.cpp

So, we have 所以,我们有

hdf5.h: No such file or directory regex.h: No such file or directory hdf5.h:没有这样的文件或目录regex.h:没有这样的文件或目录

but they are in C:\\Octave\\Octave3.2.4_gcc4.4.0\\include\\ 但它们位于C:\\ Octave \\ Octave3.2.4_gcc4.4.0 \\ include \\

I do not understand where is my mistake. 我不明白我的错误在哪里。

The solution to my problem was an issue with my gcc version. 我的问题的解决方案是我的gcc版本有问题。 It seems likely that it was incompatible with the version used to compile octave. 它似乎与用于编译八度的版本不兼容。

The corrected makefile is below: 更正的makefile如下:

OCTAVE_INCLUDE=C:\Octave\Octave3.6.4_gcc4.6.2\include

all: test

clean:
    -rm test.o test

test: test.o
    mkoctfile --link-stand-alone -o test test.o

test.o: main.cpp
    g++ -c -I$(OCTAVE_INCLUDE) -I$(OCTAVE_INCLUDE)\octave-3.6.4 -o test.o main.cpp

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

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