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