From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18729 invoked by alias); 30 Jun 2014 12:25:27 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 18696 invoked by uid 89); 30 Jun 2014 12:25:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: plane.gmane.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 30 Jun 2014 12:25:24 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X1ae7-0008Mi-S0 for cygwin@cygwin.com; Mon, 30 Jun 2014 14:25:19 +0200 Received: from ppp-93-104-50-86.dynamic.mnet-online.de ([93.104.50.86]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Jun 2014 14:25:19 +0200 Received: from soren.hein by ppp-93-104-50-86.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Jun 2014 14:25:19 +0200 To: cygwin@cygwin.com From: Soren Hein Subject: cygwin DLL and mingw main Date: Mon, 30 Jun 2014 12:25:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00443.txt.bz2 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 #include extern "C" __declspec(dllexport) int __stdcall identify() { return 17; } % cat dtest.cpp #include #include 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