Matlab mex files and cygwin

Mumit Khan
Tue Dec 22 18:38:00 GMT 1998 (Matthew Brett) writes:
> I don't know whether it's the memory allocation specifically.  In the early
> phases of my mex file attempts (which were based on Ton Overbeek's posts abou
> t
> a year ago, that you mentioned) the mex file dlls were loading, but then 
> crashing when they executed code involving  mallocs etc.  This was, I assume,
> due to the fact that the cygwin.dll was not being initialised properly, as th
> is
> was a known problem, which should have been fixed with B20.1, I think.

It's still a hack! At some point in the future, we should revisit the
issue of Cygwin initialization, but now's not the time. Essentially, there
two recommended entry points for user DLLs using Cygwin:
  - __cygwin_dll_entry@12 -- for all Cygwin DLLs (other than the Cygwin
    DLL itself of course). This is the default in dllwrap. In the future,
    this name may change to something similar to what MSVC uses, and then
    the linker will also change to use the new name.
  - __cygwin_noncygwwin_dll_entry@12 -- This is a hack to support using
    Cygwin DLLs from non-cygwin apps (and only using LoadLibrary, not via
    linking with import library). This was done primarily because of
    problems writing Java JNI's using Cygwin. I essentially tested this
    method with either MSVC apps or Java JNI, but not with Netscape (which
    definitely does not work), nor with Matlab. I should also mention that
    fork probably fails miserably with this hack, and I'm sure a few other
    things do as well.

> Now, late phase, with the new entry point to Cygwin.dll that should initialis
> e
> the Cygwin functions including malloc, in b20.1, the mex 
> file dll just crashes matlab as soon as it is called, even if no malloc-
> using code is used.  I don't know what this is due to, and don't know how
> to pursue it.  So close, it seems, and yet so far away.

As I have noted before, Netscape dies the same horrible death, and it's
quite possibly closely related (even if slightly different). 

I can build a debuggable Cygwin DLL if someone would like to run it
through a debugger and report the results back to me (or give me remote
access to an NT machine with matlab -- but that probably wouldn't work if
Matlab on Windows is a GUI app). Matthew?

> Frustrating!  But, as you say, mingw gives a useful halfway house,

Yes, but unfortunately, lots of POSIX code needs to be rewritten then. 


For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list