Reputation: 11
I have generated dll file using cygwin and I am trying to use it in Visual Studio.
In MSVC, I wrote a program which used the function from the lib file which was created.
I got Linker errors.
When I checked the mangled names,the one in DEF file is different to the one in the error thrown in MSVC.
I demangled both and found that MSVC has mangled the function name with __cdecl
keyword.
How can I create mangled function names in cygwin with __cdecl
keyword? Am I missing any flags in cgwin compilation?
Visual Studio:
Mangled name:
(__imp_?configure_tls_context@client@asio_http2@nghttp2@@YA?AVerror_code@system@boost@@AAV456@AAVcontext@ssl@asio@6@@Z)
Demangled name:
(__imp_class boost::system::error_code __cdecl nghttp2::asio_http2::client::configure_tls_context(class boost::system::error_code &,class boost::asio::ssl::context &)
DEF file from Cygwin: Mangled name:
_ZN7nghttp210asio_http26client21configure_tls_contextERN5boost6system10error_codeERNS2_4asio3ssl7contextE
Demangled name:
nghttp2::asio_http2::client::configure_tls_context(boost::system::error_code&, boost::asio::ssl::context&)
Upvotes: 0
Views: 659
Reputation: 31465
As a general rule; with C++ code you always need to compile all code for your project with the exact same compiler. This includes the executable and all static and dynamic libraries. C++ does not have a ABI specification and all compilers may mangle names differently and even new minor versions of a compiler may produce code that is incompatible with code built with previous versions. There is no standard for name mangling or data structure layout etc.
So; always recompile all source code with the exact same compiler or be prepared for a world of pain.
Upvotes: 3