在 C++ 中使用 MATLAB API,matOpen 无声地崩溃程序 [英] Using MATLAB API in C++, matOpen crashing program silently

查看:36
本文介绍了在 C++ 中使用 MATLAB API,matOpen 无声地崩溃程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于这个但它相当老了,由于我(初学者)的声誉,我无法发表评论或投票.我正在尝试像这样从 Matlab 2017b 编译 matcreat.cpp 文件(使用 g++(x86_64-posix-seh-rev0,由 MinGW-W64 项目构建)8.1.0):

my problem is similar to this one but it is rather old and I cannot comment or upvote due to my (beginners) reputation. I am trying to compile the matcreat.cpp file from Matlab 2017b like this (using g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0):

g++ -c -o matcreat.o -I"C:\Program Files\MATLAB\R2017b\extern\include" matcreat.cpp
g++ -o matcreat.exe matcreat.o -L"C:\Program Files\MATLAB\R2017b\extern\lib\win64\mingw64" -llibmat -llibmex -llibmx -llibeng

该程序有一个 main,它在开始时使用 printf(甚至在 matlab 之前),但没有输出任何内容,它只是终止.如果我注释掉所有与 MATLAB 相关的函数调用它可以工作,第一个是 pmat = matOpen(file, "w");.

The program has a main which uses printf right at the beginning (even before the matlab stuff), but nothing is put out and it just terminates. If I comment out all the MATLAB related function calls it works, the first one being pmat = matOpen(file, "w");.

为什么程序只是默默地崩溃并输出什么?为什么没有编译器/链接器错误?任何想法,不胜感激.

Why is the program just silently crashing and outputting nothing? Why no compiler/linker errors? Any ideas whout be greatly appreciated.

推荐答案

在尝试解决 mex 构建过程的内部结构一段时间后,我放弃了这条路线.Mathworks 有意让您难以将其功能整合到您自己的代码中.

After some time trying to work around the internals of the mex building process I gave up on that route. Mathworks is deliberately trying to make it hard to incorporate their features into your own code.

对于有同样问题的每个人:经过一番研究,我发现了这个开源项目,它可以写MAT文件就好了.

For everyone with the same problems: After some research I found this open source project, which can write MAT files just fine.

这篇关于在 C++ 中使用 MATLAB API,matOpen 无声地崩溃程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆