MATLAB: ModelSim – MATLAB cosimulation not running!!!

bad dllcosimulationHDL Verifiermodelsimsimulink

After starting the cosimulation in modelsim version 10.4a (by running vsimulink work.inverter) I get the following error:
# Loading D:/Program Files/MATLAB/R2017b/toolbox/edalink/extensions/modelsim/windows32/liblfmhdls_gcc421vc12.dll # Error: (vsim-3193) Load of "D:/Program Files/MATLAB/R2017b/toolbox/edalink/extensions/modelsim/windows32/liblfmhdls_gcc421vc12.dll" failed: Bad DLL format. # # Warning: (vsim-FLI-3160) Failed to load FLI object file "D:/Program Files/MATLAB/R2017b/toolbox/edalink/extensions/modelsim/windows32/liblfmhdls_gcc421vc12.dll".
I searched online and found some people saying its a 64 bit, 32 bit version problem. But the file is clearly seemed to be inside "windows32/" folder.
How can I fix this error? Stuck here for hours. Anykind of help will be very much appreciated. Thank you.

Best Answer

First, we need to determine if your ModelSim is 32-bit or 64bit. The easiest way to check this is to look at the title of ModelSim window. If it says something like "ModelSim SE-64", then you have a 64 bit ModelSim. In that case, we are loading the wrong DLL (32bit) into your ModelSim. We can further investigate why it does not work.
If there is no "-64" in your window title, then you do have a 32-bit ModelSim. It might be the problem that you don't have the visual studio redistribute installed in your machine. The shared DLL that we compiled requires Visual Studio 2013 redistribute. You can get it from Microsoft website here:
https://www.microsoft.com/en-us/download/details.aspx?id=40784
You'll need to make sure that you installed the 32-bit version.
Let me know if you still have problem. Also, please let me know the ModelSim type that you have, is it SE, PE, or DE version?