Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Avoiding name mangling in Qt dll
I have created a -QT- Qt Library.
But when i try to use that dll I see the names of all the functions in dll are name mangled.
How to avoid this?
first of all, which platform and which compiler tool chain do you use?
C++ has no definitions, how names are exported. If you want to export C style functions, you have to mark this section as C
// my C-functions to export
below is my example code
My above code is developed as -QT- Qt Library.
but when I try to use extern "C" for each function it gives me error.
Is there any keyword in QT which is equivalent to extern "C".
extern "C" only works for functions, not for class members. Class members will always be mangled names.
Why do you need that?
and you did not answer my first question:
bq. first of all, which platform and which compiler tool chain do you use?
I am using Visual studio 2010.
I want to load my dll dynamically in client application.
And use function pointers to call functions from the class.
So wat is the solution for class members to avoid name mangling.
There is no. You can't load a dll dynamically and call class members idrectly, this is not possible. If you want to use classes, use a creator design pattern with interfaces or use early binding.
ZapB last edited by
Name mangling is part of the C++ ABI you cannot disable it. You'll need to wrap the management of your C++ objects in plain C functions and be sure to mark those functions as extern "C" as Gerolf said.
lgeyer last edited by
... and you cannot use simple functions pointers to "call methods on objects":http://www.parashift.com/c++-faq-lite/pointers-to-members.html.