gpt4 book ai didi

c++ - 问题包括 MATLAB "engine.h"for C++ code

转载 作者:可可西里 更新时间:2023-11-01 15:52:44 26 4
gpt4 key购买 nike

我正在尝试运行 example code来自 MATLAB Doc,但是当我尝试在 Visual Studio 中构建项目时出现此错误

fatal error C1083: Cannot open include file: 'engine.h': No such file or directory

事实是,在文档中我无法找到链接标题的位置,他们显示的示例就好像不需要做任何其他事情一样,只需执行

#include "engine.h";

关于如何解决这个问题有什么想法吗?

编辑

我解决了第一个问题,但现在我遇到了一些与缺少库有关的错误:

1>engwindemo.obj : error LNK2019: unresolved external symbol _engClose referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxGetClassName referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engGetVariable referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engOutputBuffer referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxDestroyArray referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engEvalString referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engPutVariable referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxGetPr referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxCreateDoubleMatrix_730 referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engOpen referenced in function _main

我按照文档中的说明设置了 Path 变量,设置了 lib 路径并添加了一些库,现在我不知道还能做什么。我还重新启动了 VisualStudio,以使 Path 变量更改生效。

enter image description here提前致谢。

最佳答案

我终于解决了这个问题。我正在构建一个 WIN32 项目,而 matlab 是 x64,因此当您尝试链接 64 位平台时,VisualStudio 会出错。解决方案是在 Project Properties -> Configuration Manager 中将 Active Solution Platform 更改为 x64。

在下面有很好的解释link .

无论如何感谢您的回答,它们很有用。

所以,总结一下,要能够在VisualStudio2008和Matlab2010中用engine.h编译运行一段c++代码,需要以下步骤:

1.- 在Advanced System Settings->环境变量中设置Path变量:C:\Program Files\MATLAB\R2010a\bin\win64(或libeng.dll所在路径)

2.- 在 VisualStudio 的项目属性中,链接 C++->General 的 Additional Include 目录:"C:\Program Files\MATLAB\R2010a\extern\include"

3.- 在项目属性中,链接器->常规,附加库目录:"C:\Program Files\MATLAB\R2010a\extern\lib\win64\microsoft"

4.- 在 Linker->Additional Dependencies 中添加以下库:libeng.liblibmx.lib

5.- 按照链接中的说明,在配置管理器中将事件解决方案平台更改为 x64。

关于c++ - 问题包括 MATLAB "engine.h"for C++ code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8800439/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com