delorie.com/archives/browse.cgi | search |
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:subject:to:references:from:cc:message-id:date | |
:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; q=dns; s=default; b=gz2AR8IM9ZmPnNjv | |
QX4fZkatL3O3oVGur19SPQaUHTYG4+puFi+ZwCFLQlb3CWWgWZDvjoG4DCcc2OrB | |
U39P7s+sTMF331dMQCUgGyXRi8Eoj4b6wO4buHH80LqVbex6SUaTYVH0h/KXAPEi | |
UXLCYkL0H154jG47ayBz23yFezo= | |
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:subject:to:references:from:cc:message-id:date | |
:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; s=default; bh=sTK5TT49JZLq6P6hno3+gu | |
jZbvU=; b=RpUxxs3Xm4neXukMpwxfM7pzG+4OzVUbxTquIsBuNTzlJ1hVph5RFr | |
UCxMcPJJem+3ZAsY0mo+JHrxkpJkh54ikIUhW8/AwD+fCDnWibCLuMN+91x2dOOj | |
horxzekfMuSxSn9d3j8APDRypwiF+RuX4U1Gr80NfvDn33ubSfIEQ= | |
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: | =?ISO-8859-1?Q?No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=kaz, Kaz, it.=c2, DLLs.=c2?= |
X-HELO: | out4-smtp.messagingengine.com |
X-ME-Sender: | <xms:5Qa8WWVZYDIHb1RLc4MbrQgBzozTGSFQweOg6QFDBZubtQu44JFF7A> |
Subject: | Re: Problem with differences with DLOPEN / DLSYM compared to ubuntu (16.04) / debian (stretch). |
To: | The Cygwin Mailing List <cygwin AT cygwin DOT com> |
References: | <a39828e5534f3c67a59f404bb624c1d5 AT mail DOT kylheku DOT com> <c1ea6bf0-171d-4f71-ee4e-c79f25214975 AT fhoosh DOT com> <94ac1558-0d01-2325-5a91-92e8b867a5bd AT gmail DOT com> |
From: | Jon Turney <jon DOT turney AT dronecode DOT org DOT uk> |
Cc: | Gary Schneir <gary AT fhoosh DOT com> |
Message-ID: | <374c9eed-e6bf-76c6-ffc3-cec5c97116a5@dronecode.org.uk> |
Date: | Fri, 15 Sep 2017 17:59:14 +0100 |
User-Agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
MIME-Version: | 1.0 |
In-Reply-To: | <94ac1558-0d01-2325-5a91-92e8b867a5bd@gmail.com> |
On 15/09/2017 17:07, cyg Simple wrote: > Please consider using an interleaving method of posting on this list. > Top posting is considered rude. > > On 9/15/2017 9:51 AM, Gary Schneir wrote: >> Thanks for the response but I am a little confused by it. If Cygwin is >> supposed to provide POSIX API functionality and DLOPEN / DLSYM are >> supported in CYGWIN, then I shouldn't care about the underlying >> complexity or restrictions of running within the Windows environment and >> using DLLs. The behavior should be the same as in other POSIX environments. > > You presented your case well and I was waiting on someone familiar with > the code to respond. I'm not sure that would be Kaz, he was just trying > to be helpful from his experiences. I agree with your surmise that > Cygwin should perform similar results as Linux in this case. ... >> If you are saying that I did not include some sort of >> __declspec(dllexport) directive in my code so that it can find my >> symbols, that is something else but you indicate that you think cygwin >> hides that complexity in shared libraries. > > Actually it would be binutils, regardless of Cygwin or MinGW, that is > trying to hide the complexity of needing to supply the > __declspec([export|import]) declarations. The logic for that is a bit > confusing but if none is given then all symbols are exported. You need to decorate the symbols you wish to be visible with '__attribute__ ((dllexport))' or '__declspec(dllexport)' (MSVC syntax which is also supported by gcc) See [1] for an example of this done portably [1] https://gcc.gnu.org/wiki/Visibility Alternatively, you can use the ld flag --export-all-symbols (cf. with the ELF option --export-dynamic, which I think you must be using to get the observed behaviour on linux) to make all symbols visible. Taking your example, and making it compilable: $ cat dlopen.cc #include <iostream> #include <memory> #include <dlfcn.h> void * handle, * symbol; const char * errorStr; int main() { /* get access to the executable's symbol table */ handle = dlopen(NULL, RTLD_LAZY); errorStr = dlerror(); if (errorStr) { std::clog << "dlopen error '" << errorStr << "'" << std::endl; } if (handle) { std::clog << "handle ok " << std::endl; } else { std::clog << "handle NULL " << std::endl; } /* look up the from_string function */ symbol = dlsym(handle, "functionname"); errorStr = dlerror(); if (symbol) { std::clog << "dlsym symbol ok " << std::endl; } else { std::clog << "dlsym symbol NULL " << std::endl; } if (errorStr) { std::clog << "dlsym error '" << errorStr << "'" << std::endl; } } extern "C" __attribute__ ((dllexport)) void functionname() { } $ g++ dlopen.cc -o dlopen $ ./dlopen handle ok dlsym symbol ok -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |