【问题标题】:Compiling .mex or .oct files using mkoctfile with Octave and Visual Studio 2010 Compiler使用 mkoctfile 和 Octave 和 Visual Studio 2010 编译器编译 .mex 或 .oct 文件
【发布时间】:2012-10-02 20:27:09
【问题描述】:

我正在尝试使用 octave 环境编译基本的 c++ .mex.oct 文件。 .mex 文件只是 matlab 中的 mexcpp.cpp 文件,您可以使用

在 MATLAB 中获取该文件
edit([matlabroot '/extern/examples/mex/mexcpp.cpp']);

.oct 文件是在 [此处] 找到的简单 c++ 示例。(http://www.gnu.org/software/octave/doc/interpreter/Getting-Started-with-Oct_002dFiles.html)

为了让 Visual Studio 编译器设置 octave wiki using vcvarsall.bat 中记录的所有环境变量,我费了一番功夫。在设置编译器环境变量之前,我可以发出 mkoctfile -v --mex mexcpp.cpp 命令而没有任何错误,但没有创建文件。

相反,我必须像这样指定环境(我使用 x86):

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

现在我遇到的真正问题是编译我的.mex.oct 文件。当我尝试编译文件时,我得到:

cc-msvc -d -c -D_WIN32 -DWIN32 -D__WIN32__  -IC:\Octave-3.6.2\include\octave-3.6.2\octave\.. -IC:\Octave-3.6.2\include\octave-3.6.2\octave -IC:\Octave-3.6.2\include -Ic:/Software/VC10Libs/include -Ic:/Software/VC10Libs/include/freetype2 -Ic:/Software/VC10Libs/include -Ic:/Software/VC10Libs/include   -O2 -MD -EHsc -wd4244 -fp:strict -fp:except-   -I.  mexcpp.cpp -o mexcpp.o
cl -nologo -c -D_WIN32 -DWIN32 -D__WIN32__ -IC:\Octave-3.6.2\include\octave-3.6.2\octave\.. -IC:\Octave-3.6.2\include\octave-3.6.2\octave -IC:\Octave-3.6.2\include -Ic:/Software/VC10Libs/include -Ic:/Software/VC10Libs/include/freetype2 -Ic:/Software/VC10Libs/include -Ic:/Software/VC10Libs/include -O2 -MD -EHsc -wd4244-fp:strict -fp:except- -I. mexcpp.cpp -Fomexcpp.o mexcpp.cpp
C:\Octave-3.6.2\include\math.h(74) : fatal error C1083: Cannot open include file: 'c:/Program Files/Microsoft Visual Studio 10.0/VC/include/math.h': No such file or directory cc-msvc -d -shared  -o mexcpp.mex  mexcpp.o   -Wl,-export:mexFunction -LC:\Octave-3.6.2\lib\octave\3.6.2 -LC:\Octave-3.6.2\lib -loctinterp -loctave -lcruft link -nologo -DLL -out:mexcpp.mex mexcpp.o -LIBPATH:C:\Octave-3.6.2\lib\octave\3.6.2 -LIBPATH:C:\Octave-3.6.2\lib octinterp.lib octave.lib cruft.lib -export:mex Function dirent.lib msvcmath.lib
LINK : fatal error LNK1181: cannot open input file 'mexcpp.o'

我的 Visual C++ 目录位于 c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC,所以我不确定它为什么会在 c:/Program Files/Microsoft Visual Studio 10.0/VC 中查找?

【问题讨论】:

    标签: c++ visual-studio-2010 visual-c++ octave


    【解决方案1】:

    我发现问题出在 Octaves 'math.h' 文件中。在第 74 行,包含文件的路径被硬编码为 c:/Program Files/Microsoft Visual Studio 10.0/VC/include/math.h。 我通过更改为c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/math.h 解决了这个问题。我尝试编译 .mex.oct 文件,它们现在可以工作了!

    编辑:

    另一方面,我注意到 octave 还包括一些不存在的 Visual Studio 路径的硬编码路径。

    -Ic:/Software/VC10Libs/include -Ic:/Software/VC10Libs/include/freetype2 -Ic:/Software/VC10Libs/include -Ic:/Software/VC10Libs/include
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-21
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 2011-05-21
      • 1970-01-01
      • 1970-01-01
      • 2013-12-09
      相关资源
      最近更新 更多