[英]Error Bex while running my qt application
我正在編寫一個將markdown轉換為html的應用程序。 為此,基於“ cpp-markdown”構建了一個DLL,名為markdown2html.dll。 該dll在我的測試程序中運行良好,但在我的qt應用程序中失敗。 這是代碼:
QString tNotesTextEditor::markdown2html(QString articleContents){
QLibrary convertLib(tr("markdown2html.dll"));
std::string result;
if(convertLib.load()){
QMessageBox::information(NULL, "OK", "DLL load is OK!");
typedef std::string (*Fun)(std::string);
Fun convertFunc = (Fun)convertLib.resolve("markdown2HTML");
if(convertFunc){
QMessageBox::information(NULL, "OK", "Function is found");
std::string locale_text = articleContents.toLocal8Bit().constData();
QMessageBox::information(NULL, "OK", "to stdstring is well");
result = convertFunc("helloworld");
QMessageBox::information(NULL, "OK", "Function works well");
//QMessageBox::information(NULL, "OK", QString::fromLocal8Bit(result.c_str()));
return QString::fromStdString(result.c_str());
} else {
QMessageBox::information(NULL, "OK", "Function not found");
return NULL;
}
} else {
QMessageBox::information(NULL, "OK", "Lib not found");
return NULL;
}
}
“工作正常”消息從未顯示,並且出現錯誤消息:
問題事件名稱: BEX
應用程序名: tNotes_client.exe
應用程序版本: 0.0.0.0
應用程序時間戳: 532af665
故障模塊名稱: StackHash_0a9e
故障模塊版本: 0.0.0.0
故障模塊時間戳: 00000000
異常偏移: 0028d3c9
異常代碼: c0000005
異常數據: badc0de1
OS 版本: 6.1.7601.2.1.0.256.48
區域設置 ID: 2052
其他信息 1: 0a9e
其他信息 2: 0a9e372d3b4ad19135b953a78882e789
其他信息 3: 0a9e
其他信息 4: 0a9e372d3b4ad19135b953a78882e789
如網站上所述,我已將DEP關閉到我的應用程序: 問題事件名稱:BEX,錯誤消息
但這不起作用。
最后,我發現Qt創建者的默認編譯器是mingw,但是dll是使用VC編譯的。 這兩個編譯器之間應該存在一些區別,並且std :: string(在我的情況下為“ helloworld”)無法正確傳遞給DLL中的函數。
因此,我的解決方案是使用同一編譯器編譯所有代碼。 謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.