From: Soren Hein <soren.hein@gmail.com>
To: cygwin@cygwin.com
Subject: cygwin DLL and mingw main
Date: Mon, 30 Jun 2014 12:25:00 -0000 [thread overview]
Message-ID: <loom.20140630T141818-298@post.gmane.org> (raw)
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
next reply other threads:[~2014-06-30 12:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 12:25 Soren Hein [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20140630T141818-298@post.gmane.org \
--to=soren.hein@gmail.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).