I am trying to follow the procedure in the help topic "Compiling and Linking MAT-File Programs" to create a MAT-file. I am running 64-bit MATLAB 2013a on Windows XP. I installed Microsoft SDK 7.1, copied the matcreat.cpp file to C:\test, and entered the following command:
mex ('-v', '-f', [matlabroot '\bin\win64\mexopts\mssdk71engmatopts.bat'], 'c:\test\matcreat.cpp')
The mex command did not give any errors and two files were created in the My Documents\MATLAB directory: matcreat.exe and matcreat.mexw64. Next I typed in the command line:
matcreat
and MATLAB gave an error: "Invalid MEX-file c:\...\matcreat.mexw64': c:\...\matcreat.mexw64 is not a valid Win32 application."
When I opened matcreat.exe in Dependency Walker, libmx.dll and libmat.dll are shown with an error: "The system cannot find the file specified."
What am I doing wrong?

 채택된 답변

James Tursa
James Tursa 2013년 4월 2일
편집: James Tursa 2013년 4월 2일

1 개 추천

Are you trying to create a mex function to run from the MATLAB environment, or are you trying to create a program (i.e., an exe) that runs and creates mat files? I am confused because your use of the mxxdk71engmatopts.bat file indicates that you are trying to create an exe file that runs separate from MATLAB (that's what that bat file does), but your effort in typing in matcreat at a MATLAB command line indicates you want a mex function instead.
I checked the code, and matcreat.cpp is intended to be a program (i.e., an exe) not a mex function. So you can't call it as a mex function. Instead,you can invoke the program at the MATLAB command line with the bang operator:
!matcreat
I.e., type an excalamation point followed by the program name. MATLAB will act as a display console for the program while it is running. The only caveat is that the display buffering for MATLAB running as a display console doesn't work properly, so sometimes you will not see any program screen output until the program actually ends.

댓글 수: 2

Jeremy
Jeremy 2013년 4월 2일
편집: Jeremy 2013년 4월 2일
I invoked the program with the bang operator and MATLAB created the MAT file as expected. Thanks!
while i compile by using the "mex ('-v', '-f', [matlabroot '\bin\win64\mexopts\mssdk71engmatopts.bat'], 'c:\test\matcreat.cpp')", get the error :Error: Could not find the compiler "cl" on the DOS path. Use mex -setup to configure your environment properly. while I am sure that i am used "mex -setup".

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

태그

질문:

2013년 4월 2일

댓글:

2016년 3월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by