I have a problem sharing "std::string" data between MS Visual C++ DLL library and Qt program.
What I have are:
DLL library written in Visual C++ 2010 Express, which exports one method:
extern "C" __declspec(dllexport) int Init(ITest* commandTest);
Abstract interface "ITest" and a class implementing it:
class CTest: public ITest { public: CTest(); virtual ~CTest(); virtual void getVersion(std::string & version) const; };
Qt GUI application that needs to:
* load the DLL dynamically * instantiate CTest and pass it to exported Init method.
In DLL's "Init" a "CTest::getVersion()" method is called. I'd expect it would get the "&version" string filled in. What I get instead are crashes on the line when I fill "&version" with new string.
What I already did:
downloaded "Qt libraries 4.8.3 for Windows (VS 2010, 235 MB)" from http://qt-project.org/downloads, installed it and selected it in QtCreator's project settings.
in QtCreator switched from MinGW toolchain to the one installed with MS Visual Studio 2010 Express.
I thought that it will overcome the problem , because I used Qt libraries compiled with VS 2010 and the Qt GUI was also compiled with VS C++ toolchain then. Unfortunately the problem was not gone, so I tried the last step:
created Win32 Console application in Visual Studio, loaded my DLL via LoadLibrary, used "Init" method the same way as I did in Qt GUI... and it worked!!
Small observation
In "CTest::getVersion()" I am printing this "version" string passed by reference to the console. When using VS C++ console app as a host it is printed out correctly. When using Qt app - the "version" string is printed with some garbage around (e.g. ┌►☻qwerty27)
This makes me think that ABI of Qt app and my DLL is still incompatible, even when using Qt VS 2010 libraries mentioned above.
Questions:
- Is using Qt libraries for Windows (VS 2010) and Visual Studio toolchain not enough to overcome ABI compatibility issues?
- Does it mean I should compile the Qt framework on my own?
- Please help - any ideas are welcome...