public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Linking a native msvc dll library to CYGWIN g++ compiler
@ 2023-07-11  6:47 Mümin A.
  2023-07-12  6:24 ` Csaba Ráduly
  2023-07-17  6:58 ` Mümin A.
  0 siblings, 2 replies; 4+ messages in thread
From: Mümin A. @ 2023-07-11  6:47 UTC (permalink / raw)
  To: cygwin


[-- Attachment #1.1: Type: text/plain, Size: 587 bytes --]

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.


Thank you in advance,
Mumin AYDIN

[-- Attachment #2: fooCls.h --]
[-- Type: text/plain, Size: 352 bytes --]

#ifndef FOOCLS_H
#define FOOCLS_H

#if defined(_WIN32)
#ifdef DLL_EXPORT
#define _WIN_DLL __declspec(dllexport)
#else
#define _WIN_DLL __declspec(dllimport)
#endif
#else
#define _WIN_DLL
#endif

namespace fooNameSpace
{

    class _WIN_DLL fooConnectionCls
    {
    public:
        void FooTest();
    };

}

#endif // FOOCLS_H

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linking a native msvc dll library to CYGWIN g++ compiler
  2023-07-11  6:47 Linking a native msvc dll library to CYGWIN g++ compiler Mümin A.
@ 2023-07-12  6:24 ` Csaba Ráduly
  2023-07-17  6:58 ` Mümin A.
  1 sibling, 0 replies; 4+ messages in thread
From: Csaba Ráduly @ 2023-07-12  6:24 UTC (permalink / raw)
  To: cygwin

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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linking a native msvc dll library to CYGWIN g++ compiler
  2023-07-11  6:47 Linking a native msvc dll library to CYGWIN g++ compiler Mümin A.
  2023-07-12  6:24 ` Csaba Ráduly
@ 2023-07-17  6:58 ` Mümin A.
  2023-07-17  8:04   ` Mark Geisert
  1 sibling, 1 reply; 4+ messages in thread
From: Mümin A. @ 2023-07-17  6:58 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

Hi,

reminder..

Mümin A. <muminaydin06@gmail.com>, 11 Tem 2023 Sal, 09:47 tarihinde şunu
yazdı:

>
> 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.
>
>
> Thank you in advance,
> Mumin AYDIN
>
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linking a native msvc dll library to CYGWIN g++ compiler
  2023-07-17  6:58 ` Mümin A.
@ 2023-07-17  8:04   ` Mark Geisert
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Geisert @ 2023-07-17  8:04 UTC (permalink / raw)
  To: cygwin

Mümin A. via Cygwin wrote:
> Hi,
> 
> reminder..
> 
> Mümin A. <muminaydin06@gmail.com>, 11 Tem 2023 Sal, 09:47 tarihinde şunu
> yazdı:
> 
>>
>> 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.
>>
>>
>> Thank you in advance,
>> Mumin AYDI

Did you see Csaba's reply to your initial email?  Check the mail archives.
Does FAQ 6.36 describe your situation?

See the Cygwin home page https://cygwin.com for pointers to those resources.

..mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-17  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11  6:47 Linking a native msvc dll library to CYGWIN g++ compiler Mümin A.
2023-07-12  6:24 ` Csaba Ráduly
2023-07-17  6:58 ` Mümin A.
2023-07-17  8:04   ` Mark Geisert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).