Problems using a DLL with Cygwin 64 bit

Corinna Vinschen
Thu Dec 17 12:43:00 GMT 2015

On Dec 17 11:00, Philip Taylor wrote:
> Environment:
> Windows 7 (64 bit)
> Cygwin 64 bit
> GCC version: 4.9.3
> To make use of a Prosilica camera, I am having to build applications using
> an externally supplied DLL (from the camera manufacturer, with no source
> code) in Cygwin64 and Cygwin32.  I am using the appropriate 32 or 64 bit
> version of the DLL, as supplied.

I take it you simply linked against the Cygwin DLL?  You're not trying
to load the Cygwin DLL at runtime dynamically?  All bets are off in the
latter case.

> The most difficult problem encountered is when using Cygwin 64 bit. I was
> initially unable to link but, using pexports and dlltool, I managed to
> create a .lib file with which I linked OK. This got rid of the initial link
> failure message "error adding symbols: File in wrong format."

Linking against the externally supplied DLL you mean?  I hope you didn't
create another link lib for Cygwin...

> But having linked successfully, the application now crashes on startup:
> $ ../../bin/cygwin-x86_64/prosilicaApp.exe
>   6 [main] prosilicaApp (96896) C:\cygwin64\home\EPICS\R3.14.12.5\modules\areaDetector\2-2\ADProsilica\2-1\iocs\prosilicaIOC\bin\cygwin-x86_64\prosilicaApp.exe:
> *** fatal error - cygheap base mismatch detected - 0x1802FA400/0x6EA400.
> This problem is probably due to using incompatible versions of the cygwin DLL.
> Search for cygwin1.dll using the Windows Start->Find/Search facility
> and delete all but the most recent version.  The most recent version *should*
> reside in x:\cygwin\bin, where 'x' is the drive on which you have
> installed the cygwin distribution.  Rebooting is also suggested if you
> are unable to find another cygwin DLL.
> Segmentation fault
> The reference to cygwin DLL in the long error message appears spurious -
> there is only one cygwin DLL in my system and there are no problems running
> other Cygwin applications in the same environment.

It is spurious in this case.  The Cygwin DLL is supposed to be located
at address 0x180040000.  The cygheap location is dependend on that since
it's immediately attached to the DLL.  It appears that, after either
forking or execing the application, the Cygwin DLL gets loaded to an
address 0x600000 or something like that.  Why this happens, I have no
idea.  Off the top of my head it points to a few possible reasons:

- The externally supplied DLL has been loaded to the 0x180000000 range.
  In that casse you should rebase it to an address which does not
  collide with other Cygwin DLLs.  An address < 0x80000000 or
  > 0x7FF000000000 would make sense.

- The externally supplied DLL has loaded data to an address in
  the 0x180000000 range, which would be weird, but is possible.

- Your application has been built with ASLR enabled.  Remove the flag
  (peflags -d0 your_app.exe) and try again.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <>

More information about the Cygwin mailing list