delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/06/30/08:25:44

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=yPO
4PjIE7HFSvDcV5wuDZleRmli8Z0NYHONZBeHP6lru+EAZv4oa/8JDJbwXs/TZNQa
Ar2hi7bWHFXNcTs5K0G8L9I66kvtKwZKsBWLupzHo3QDAjzzv80khvsNevyCaAiP
1bvH4KQfNTFE+NZkUVuDSH05BOU6K9xYM7q9sPTg=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:mime-version
:content-type:content-transfer-encoding; s=default; bh=LKCdadjI+
uIgWCniuaXnP/zCLOY=; b=L3bZYpks20SedAwPgkn8f004OVX05kdbszlE/erE1
GD1UaVlPjIi5x80cDre0xLZwV1NJ+X9d0I2mDhf7tH/QwPjzDRU58bwvMWVOU0YX
JPO3zalbj6S36lBG46UW0tPrrntMntO9RA14YYoeUv+nBakjykh+pRB5NZTRLCc6
Ls=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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
To: cygwin AT cygwin DOT com
From: Soren Hein <soren DOT hein AT gmail DOT com>
Subject: cygwin DLL and mingw main
Date: Mon, 30 Jun 2014 12:25:03 +0000 (UTC)
Lines: 54
Message-ID: <loom.20140630T141818-298@post.gmane.org>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019