This is the mail archive of the
cygwin
mailing list for the Cygwin project.
cygwin DLL and mingw main
- From: Soren Hein <soren dot hein at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 30 Jun 2014 12:25:03 +0000 (UTC)
- Subject: cygwin DLL and mingw main
- Authentication-results: sourceware.org; auth=none
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