Error '.mexw64 is not a valid Win32 application' while building a Simulink model with S-function blocks.
Show older comments
I am working on porting an old MATLAB 7.1 32bit Simulink library to a newer MATLAB version (MATLAB 2022 64bit). This library utilizes S-function blocks.
In the old library version, these S-functions referenced some .dll files generated from source .c files using the MATLAB mex command.
To be able to use the library in MATLAB 2022, I attempted to recompile the source .c files with the mex command, and they now have the .mexw64 extension.
I also recompiled the .lib libraries on which these .c files depend using Visual Studio 2022, ensuring they are compatible with 64-bit programs. I provided them as inputs during the mex function calls (with the arguments -I, -L, and -l).
For example this is how i generate the .mexw64 file for a call_simul_mng.c file:
mex -v -I.\..\..\..\libraries\dsp_base_sw\include ...
-LC:\Users\522397\source\repos\mclk_lib\x64\Release ...
-lmclk_lib.lib ...
-I.\..\..\..\libraries\var_db_lib\src ...
-LC:\Users\522397\source\repos\var_db_lib\x64\Release ...
-lvar_db_lib.lib ...
call_simul_mng.c
where the mclk_lib.lib and var_db_lib.lib libraries are the ones i recompiled on visual studio 2022.
However, when I open a model that uses the library blocks and try to use the 'Update Model' command on the Simulink toolstrip to check if the model can compile and simulate, I encounter the following error: 'XXX.mexw64 is not a valid Win32 application', where XXX is the name of the S-function executable.
Can anyone help me?
1 Comment
Saurabh
on 9 Dec 2024
Check out this MATLAB answer thread and check if this could solve the issue you are encountering:
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!