X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98A7B3857C40
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1689143112;
	bh=4DZzXldh115fhp5wzVth6hej8kV6diLF4xt4p8RLZCI=;
	h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=vsSl6/r6SiF22om4jxOScT7VL7M0ynqegbiYqgsuKW+x/V+vbcCJ72iuSC4MpMhKr
	 wz0zotGMl95UJLnbkslcxp6w22FQNU44pK8OiJcaPG/iKIcyT4KLLHz1PKy7ZKQMu6
	 YmsSvFmXiJQl9BAuP8V9OP0+BYdQh2DwqzvtIjMc=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D75153858D38
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1689143074; x=1691735074;
 h=content-transfer-encoding:in-reply-to:from:references:to:subject
 :user-agent:mime-version:date:message-id:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=IrXoHDKELrsiXJBcaj4m3tQ8Vk3IVF81/NYK5m4xc4U=;
 b=D2q1I9c6UqOVZi/D3ipzTTLtriYs8b0P/AZ7p6svVM4gkkXcbOM2vSzsR91RRebQg+
 QDQ88iQUgWzf+cz5/WaWS/zOL9g6SagCgXXi2j6GKb62nXpG6WQolctc2cKrHyiyFF9G
 54NDGSmX4AkHzEJhEgv6Ld1uGEDnI+4u3uYSWW3X8tzgorPtD2ebP4EWFOJmLSxQUrRT
 7Y8T19b5M0yH1rJnLtw6deLvVAqJ1yOn0CPFl41XGa4szYZQTRC2l9QIlvOzQ7VTKMAT
 eITRr0MS6jPrzEuyt8oDhbB9H8PDONwXQmchicptyy7X136Ryw2qJfginLNYJ6f0OfaA
 aCNg==
X-Gm-Message-State: ABy/qLZXCuW1lrj8WPKPLs2cncAvjfTwzMccmi92bxOzho9y3b9xtC3a
 F1ed532c7nPnXUBI3gyIlioGfaXv++M=
X-Google-Smtp-Source: APBJJlHOED9ROr80VJmYaYT0yCVKdO/qP4UTlkwz4JHZi/NjzIhwaAk4T1qHXHxWB2MJdPOdabJIbA==
X-Received: by 2002:a17:906:209d:b0:973:d06d:545f with SMTP id
 29-20020a170906209d00b00973d06d545fmr16469773ejq.24.1689143074414; 
 Tue, 11 Jul 2023 23:24:34 -0700 (PDT)
Message-ID: <eb49a355-95ad-b99f-d45e-19ff0ee94017@gmail.com>
Date: Wed, 12 Jul 2023 08:24:29 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Subject: Re: Linking a native msvc dll library to CYGWIN g++ compiler
To: cygwin@cygwin.com
References: <CAPxKPA4KfwWUa4pgEBuN=3ZDTYLP2QNGNo39nKhUtXFF_zGQ2A@mail.gmail.com>
In-Reply-To: <CAPxKPA4KfwWUa4pgEBuN=3ZDTYLP2QNGNo39nKhUtXFF_zGQ2A@mail.gmail.com>
X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A,
 RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP,
 T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: =?utf-8?q?Csaba_R=C3=A1duly_via_Cygwin?= <cygwin@cygwin.com>
Reply-To: =?UTF-8?Q?Csaba_R=c3=a1duly?= <rcsaba@gmail.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 36C6Pc6x003635

On 11/07/2023 08:47, Mümin A. via Cygwin wrote:
> Hi,
>
> I'm facing a problem while linking my native dll library into the g++
> compiler.
>
> There is a name mangling problem when calling a msvc function from g++
> compiler therefore linker gives an error undefined reference.
>
> Is there any method to directly link and call a function from native dll
> library from the cygwin compiler ?
>
>
>
> For example, I've a fooCls.h header file for a windows library,  I add link
> the fooCls.dll to g++ compiler then,
>
> fooNameSpace::fooConnectionCls instance;
> instance.FooTest();
>
> gives a linker error , undefined reference.

Hi,

GCC (and most compilers on Unix-like systems, even macOS) use the 
Itanium (IA64) ABI for C++ mangling:

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling

MSVC uses a different scheme, so the name of the symbol (as seen by the 
linker) expected by the object file compiled by GCC is different from 
the symbol supplied by the object file compiled with MSVC.

To link object files from GCC and MSVC together, you need to use C 
linkage (extern "C").

Csaba

-- 

Life is complex, with real and imaginary parts.




-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

