Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I originally thought this sounded like a form of torture, but based on the above answer by @user10171136 I actually found it pretty straightforward to cross-compile for Windows mex from Fedora Linux. Fedora has mingw and mingw64 packages, so:</p> <ol> <li><code>sudo yum install mingw64-gcc mingw64-gcc-c++</code></li> <li>Copy over from a Windows Matlab install both the <code>extern/include</code> and <code>bin/win64</code> directories (actually you probably only need a subset of the headers and a small subset of the dlls; <code>libmat.dll libmex.dll libmx.dll</code> might be all you need. I put these two directories into a new <code>R2010a-w64</code> directory under my existing Linux MATLAB directory; change the below commands appropriate for where you stashed the Windows headers and libs.</li> <li>There was one problem I ran into, which is that <code>char16_t</code> was needed in <code>matrix.h</code> and wasn't defined. I guess <code>matrix.h</code> forgot to include <code>uchar.h</code>? I worked around with an <code>-include</code> directive; see below.</li> <li><code>x86_64-w64-mingw32-gcc -m64 -shared -include uchar.h -I/opt/MATLAB/R2010a-w64/extern/include -DMATLAB_MEX_FILE -L/opt/MATLAB/R2010a-w64/bin/win64 -o bla.mexw64 bla.c -lmx -lmex</code></li> <li>(You may need additional libraries for linking, e.g. -lmat -leng -lm, etc.)</li> <li>This successfully generates a mex file that is executable under Windows Matlab for my setup. So far I've only tested this with pretty simple C programs.</li> </ol> <p>Interested to hear if this sounds reasonable; I don't have much experience with cross-compiling.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload