【发布时间】:2017-01-08 23:10:20
【问题描述】:
我尝试在我的 Octave 的 c++ 项目库中使用。 不幸的是,我无法构建程序。 我使用的是 Windows 7 64 位、Octave3.6.4_gcc4.6.2 和 gcc 4.6.2。
我的步骤:
- 已下载 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)
我安装在 C:\Octave 中。我在环境变量PATH中添加了octave的bin文件夹地址。
已下载 mingw32-gcc-4.6.2-release-c,c++,fortran-sjlj-FINAL.7z 并安装在C盘。我已经将mingw的bin文件夹地址添加到环境变量PATH中了。
尝试编译简单示例 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;
}
- 我使用了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
所以,我们有
hdf5.h: 没有这样的文件或目录 regex.h: 没有这样的文件或目录
但它们在 C:\Octave\Octave3.2.4_gcc4.4.0\include\
我不明白我的错误在哪里。
【问题讨论】:
-
好吧,你说文件的头文件在“C:\Octave\Octave3.2.4_gcc4.4.0\include\”,你告诉
g++在“C: \Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4" 和 "C:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4octave",两者都不是 "C:\ Octave\Octave3.2.4_gcc4.4.0\include\". -
Mike,我如何告诉编译器必要的头文件在 "C:\Octave\Octave3.2.4_gcc4.4.0\include\" 中?
-
你已经这样做了! - 使用
-I<directory>选项。只需指定正确的<directory>(s)。 -
我明白,但我不知道如何指定两个路径以包含在我的案例中
-
使用多个
-I<dir>选项。编译器将按照指定的顺序搜索它们,直到成功或最终失败。看起来你基本上不了解如何使用 GCC 和 GNU Make,而且它超出了 Stackoverflow 的目的来解决这个问题。 Here is a fairly sound beginner's tutorial。对于权威文档,here is the GCC manual 和 here is the GNU Make manual。