From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id D75153858D38 for ; Wed, 12 Jul 2023 06:24:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D75153858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-992acf67388so754066066b.1 for ; Tue, 11 Jul 2023 23:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689143074; x=1691735074; h=content-transfer-encoding:in-reply-to:from:references:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=IrXoHDKELrsiXJBcaj4m3tQ8Vk3IVF81/NYK5m4xc4U=; b=DUu2fIsiE0uMTTkVDuVcixnPlYaUosTwSOu48DNzLJZNABntIVYfzOX7GF8k7iAU1z cSS3i3wDGHrRK2BD3j1r8e0GCSHeBxfeMODyX+Nn1MW3t4Zd4xNQKMxiHFU4PLbD7frX t6wewmrKAKzd2wTNTshgsOa2+STIL5w1sjtv5tBfgLCUCGAfQRgglFRJYG8FGOcGaE5o 6sc5tVxTy/Fq88/cWklbr97qtabyiCDhmmUZa9D+uABRbjIB4CKQvJKpGlWuBszREUmH w3mQHs9RWdjy8nw59j+Ap5kwMk7QeL/b/7axQzr/8s2uZxMl+As/uAnS0RkCxHHTvoXc prng== 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) Received: from [192.168.1.122] (84-236-97-105.pool.digikabel.hu. [84.236.97.105]) by smtp.gmail.com with ESMTPSA id dk7-20020a170906f0c700b009931a3adf64sm2121839ejb.17.2023.07.11.23.24.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jul 2023 23:24:33 -0700 (PDT) Message-ID: 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: From: =?UTF-8?Q?Csaba_R=c3=a1duly?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 List-Id: 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.