Invalid Mex-function

2019-07-26 07:25发布

问题:

I am quite experienced with matlab mex functions, but I am having a problem very difficult to solve.

I am receiving a message like this:

Invalid MEX-file 'mymex.mexw64': The specified procedure could not be found.

Normally, this problem is related to missing dlls. However, I checked several times with dependency walker and nothing is missing.

Also, I checked with "alternative" softwares, eg: ProcessMonitor, ProcessExplorer, CFF_Explorer... and so on. I have tried everything.

The problem started when I tried to migrate an old code from Matlab2012 to Matlab2015.

In this process :

  1. I updated libmx, libmex to the current ones (2015)
  2. Changed qt version to a new version (yes, my mex function uses qt)
  3. Changed platform to v140 (the old one was v110, Visual Studio 2012)

My only hypothesis is that something with some custom *.lib files used. These lib files are compiled in v110, and I am using v140. In my distribution package I have included the dlls to both Visual C++ Redistributable Packages v110 e v140. I am not sure if this is possible, although the source code is compiling just fine.

I have not tested removing these *.libs, because this would be quite painful

My questions are:

  1. Is my hypothesis valid?
  2. Does anyone know how to solve this?

回答1:

I figured out the answer myself. It turns out that simulink uses qt internally. So, the Dlls from my custom app is conflicting with simulink QT dlls. Both have the same name, but simulink is using a slightly different version of QT.

QT states that using the same major version you can have backwards compatibility... But that is not the case, at least not in matlab environment.



标签: c++ matlab mex