필터 지우기
필터 지우기

'Not a valid win32 application' error - using mex files with Matlab 2011b and Visual C++ 2010 Express

조회 수: 40 (최근 30일)
Hello
I have C++ project which compiles in Visual C++ 2010 Express, which I have set as my compiler using mex -setup in MatLab R2011b, but when I try to run this mex file from an m-file in Matlab I get the following error:
Invalid MEX-file 'C:\Users\Ellen W\Documents\Visual Studio 2010\Projects\Simulate\Debug\simulate.mexw32': C:\Users\Ellen W\Documents\Visual Studio 2010\Projects\Simulate\Debug\simulate.mexw32 is not a valid Win32 application.
I followed online instructions exactly about what settings I need for the project. My computer is Windows 7 Professional, 32bit operating system.
Thank you in advance for your help!
  댓글 수: 2
Paola
Paola 2015년 2월 19일
편집: Paola 2015년 2월 19일
I have a similar problem. In MATLAB 2012b 64 bit, when setting up the compiler, it was found when using the mex -setup command:
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler: [1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
However, for MATLAB 2014b 32-bit, it does not show me any other available compiler than the lcc-win32 and just the Microsoft Software Development Kit (SDK) 7.1, which seems not to be linked to Microsoft Visual Studio somehow. With each compiler I get different errors when trying to use precompiled mex-functions (both for 32 and 64 bits). For 64 bits, they are working ok. When using the lcc compiler, I get the same error, which tells me the mex32 function is not a valid Win32 application. I cannot find the way to make this work.

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

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 5월 18일
Is there a reason that you don't compile directly using the "mex" command in MATLAB? The most likely issue could be that the MEX-file depends on Visual Studio redistributables (DLLs) which are not on the System path, so MATLAB is unable to load them, which is necessary to run the MEX-file. Could you try running your MEX-file through Dependency Walker and see if you can find the missing dependencies.

추가 답변 (1개)

Mike Woodward
Mike Woodward 2012년 6월 26일
You might find the following download helpful: http://www.mathworks.com/programs/simulink-visual-studio/simulink-and-visual-studio.html - it's for Windows 64 - but it should point you in the right direction.
Mike

카테고리

Help CenterFile Exchange에서 Troubleshooting in MATLAB Compiler SDK에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by