public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygwin DLL and mingw main
@ 2014-06-30 12:25 Soren Hein
  2014-06-30 12:44 ` ezmlm problems with yahoo/AT&T senders tednolan
  2014-06-30 13:25 ` cygwin DLL and mingw main Jan Nijtmans
  0 siblings, 2 replies; 5+ messages in thread
From: Soren Hein @ 2014-06-30 12:25 UTC (permalink / raw)
  To: cygwin

Below are (1) a simple dll (dds.dll) and (2) a simple main program 
(dtest.cpp).  After much experimentation I have reduced my problem to this 
tiny test case.

If I compile (1) with cygwin and (2) with mingw, the resulting program 
segfaults when run.

(1) with cygwin and (2) with cygwin works.
(1) with mingw and (2) with mingw works.
(1) with mingw and (2) with cygwin works.

There are also combinations with Microsoft cl that work.

Why does it segfault?  It's driving me nuts.

g++ v4.8.3, mingw v4.8.2.
% uname -a
CYGWIN_NT-6.1-WOW64 CDD-NB01 1.7.30(0.272/5/3) 2014-05-23 10:36 i686 Cygwin


Thanks,
Soren
-----

% cat dds.cpp
#include <windows.h>
#include <stdio.h>

extern "C" __declspec(dllexport) int __stdcall identify()
{
  return 17;
}

% cat dtest.cpp
#include <windows.h>
#include <stdio.h>

extern "C" __declspec(dllimport) int __stdcall identify();

int main(int argc, char * argv[])
{
  printf("Return value is %d\n", identify());
  return TRUE;
}


This compilation leads to the fail:
g++ -o dds.dll -shared dds.cpp -Wl,--subsystem,windows
i686-w64-mingw32-g++ -o dtest dtest.cpp -Wl,--subsystem,windows -L./ -ldds

This compilation works:
i686-w64-mingw32-g++ -shared dds.cpp -Wl,--subsystem,windows -o dds.dll
g++ dtest.cpp -Wl,--subsystem,windows -L./ -ldds -o dtest



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-30 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-30 12:25 cygwin DLL and mingw main Soren Hein
2014-06-30 12:44 ` ezmlm problems with yahoo/AT&T senders tednolan
2014-06-30 13:42   ` Larry Hall (Cygwin)
2014-06-30 13:53     ` tednolan
2014-06-30 13:25 ` cygwin DLL and mingw main Jan Nijtmans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).