DLL библиотеки Visual Studio C ++ вылетает в приложении Qt

У меня проблема с совместным использованием & quot; std :: string & quot; данные между библиотекой MS Visual C ++ DLL и программой Qt.

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.

В DLL & s; Init & quot; & quot; CTest :: getVersion () & quot; метод называется. Я ожидаю, что он получит & amp; версию & quot; заполненная строка. Вместо этого я получаю сбои в строке при заполнении & amp; version & quot; с новой строкой.

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

В & quot; CTest :: getVersion () & quot; Я печатаю эту «версию» строка передается по ссылке на консоль. При использовании консольного приложения VS C ++ оно распечатывается корректно. При использовании приложения Qt - «версия» строка напечатана с небольшим количеством мусора вокруг (например, & # x250C; & # x25BA; & # x263B; qwerty27)

Это заставляет меня думать, что ABI приложения Qt и моей DLL по-прежнему несовместимы даже при использовании библиотек Qt VS 2010, упомянутых выше.

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...

Ответы на вопрос(2)

Ваш ответ на вопрос