【问题标题】:How to include "matlabengine.hpp" and "MatlabDataArray.hpp" files in gcc's search path on windows using 64-bits MinGW and 32-bits Matlab?如何在使用 64 位 MinGW 和 32 位 Matlab 的 Windows 上的 gcc 搜索路径中包含“matlabengine.hpp”和“MatlabDataArray.hpp”文件?
【发布时间】:2020-09-23 06:21:23
【问题描述】:

我有一个名为 call_mat.cpp 的文件,开头有两条语句:

\#include "MatlabDataArray.hpp" and    \#include "MatlabEngine.hpp"

These headers files are not on "gcc" default search path. They are in the folder "C:/Programmes/MATLAB/R2018a/extern/include". I tried the "-I" option to include them when running my code using the following command:

gcc -c -I/C:/Programmes/MATLAB/R2018a/extern/include call_mat.cpp

我收到以下错误:

call_mat.cpp:1:10: fatal error: MatlabDataArray.hpp: No such file or directory
    1 | #include "MatlabDataArray.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

【问题讨论】:

    标签: c++ matlab gcc mingw matlab-engine


    【解决方案1】:

    您是在 MSYS2 shell 下执行此操作吗? 如果是这样,您应该使用:

    -IC:/Programmes/MATLAB/R2018a/extern/include
    

    或:

    -I/C/Programmes/MATLAB/R2018a/extern/include
    

    甚至可能:

    -I'C:\Programmes\MATLAB\R2018a\extern\include'
    

    如果您没有使用任何类型的 *nix-like shell(或普通的命令提示符或 PowerShell),您可以使用:

    -I "C:\Programmes\MATLAB\R2018a\extern\include"
    

    【讨论】:

    • 我用的是windows的经典cmd。所以,我尝试了你给我的最后一个命令,它仍然产生同样的错误。 >gcc -c -I"C:\Programmes\MATLAB\R2018a\extern\include" call_mat.cpp
    • 我还注意到您使用 gcc 但包含文件是 .hpp 文件。看起来你应该使用 g++ 而不是 gcc...
    • 你可以先试试SET CPLUS_INCLUDE_PATH=C:\Programmes\MATLAB\R2018a\extern\include,然后再试试g++ -c call_mat.cpp吗?
    • 添加“SET CPLUS_INCLUDE_PATH=C:\Programmes\MATLAB\R2018a\extern\include”后仍然显示相同的错误消息
    • 你能在命令提示符下运行DIR C:\Programmes\MATLAB\R2018a\extern\include\MatlabDataArray.hpp而不会出错吗?
    猜你喜欢
    • 1970-01-01
    • 2011-06-20
    • 1970-01-01
    • 2012-05-19
    • 2011-07-16
    • 2011-09-02
    • 2010-11-01
    相关资源
    最近更新 更多