MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   将Matlab共享库链接到Qt(Windows) (https://www.labfans.com/bbs/showthread.php?t=26191)

poster 2019-12-14 20:13

将Matlab共享库链接到Qt(Windows)
 
我想在Windows下的QT([url]http://www.mathworks.com/help/techdoc/matlab_external/f39876.html#bsfvqhp-1)中使用Matlab的C[/url] API来打开.mat文件。在我的.pro文件中,我包含了INCLUDEPATH += "C:\Program Files\MATLAB\R2010b\extern\include" ,它可以正常工作(代码可以编译)。但是,当尝试使用LIBS += -L"C:\Program Files\MATLAB\R2010b\extern\lib\win32\microsoft" -llibmat链接libmat.lib文件(我已阅读.dll文件无法直接链接)时应用程序在执行时崩溃。给出的错误说[file].exe exited with code -1073741515

我既不是QT也不是Windows专家,但是对于这个项目,我被迫同时使用两者(我想在GNU / Linux中更容易解决此问题),因此将不胜感激。使用Windows XP,带有Qt Creator 2.0.1的QT版本4.7.0和Matlab R2010b。

万一有用,编译器的最后输出:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug/MainUI.exe debug/main.o debug/maingui.o debug/matparser.o debug/matutils.o debug/moc_maingui.o -L'c:/Qt/2010.05/qt/lib' -lmingw32 -lqtmaind "-LC:\Program Files\MATLAB\R2010b\extern\lib\win32\microsoft" -llibmat -lQtGuid4 -lQtCored4



[B]回答:[/B]

我刚刚测试过构建一个简单的C程序,该程序使用[URL="http://www.mathworks.com/help/matlab/read-and-write-matlab-mat-files-in-c-c-and-fortran.html"]MAT文件接口库[/URL]没有问题。该示例文件位于: [URL="http://www.mathworks.com/help/matlab/matlab_external/list-of-examples.html"]matlabroot/examples/eng_mat/matcreat.c[/URL] 。我正在Windows XP 32位计算机上使用[URL="http://www.mingw.org/"]MinGW[/URL]进行编译。这是我使用的Makefile:

# root directory of MATLAB installation MATLABROOT="/c/Program Files/MATLAB/R2010b" .PHONY : all clean run all: matcreat matcreat: gcc ${MATLABROOT}/extern/examples/eng_mat/matcreat.c -o matcreat \ -I${MATLABROOT}/extern/include \ -L${MATLABROOT}/extern/lib/win32/microsoft -llibmat -llibmx clean: rm -rf matcreat *.exe *.mat run: # UNIX uses LD_LIBRARY_PATH to find libs at runtime, Windows/MinGW uses PATH @PATH=${MATLABROOT}/bin/win32:"${PATH}" ./matcreat

[url=https://stackoverflow.com/questions/4734781]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:19

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.