简体   繁体   English

运行我的Qt应用程序时出现错误Bex

[英]Error Bex while running my qt application

I am writing an application to convert markdown to html. 我正在编写一个将markdown转换为html的应用程序。 And built a dll based on "cpp-markdown" for this purpose, named markdown2html.dll. 为此,基于“ cpp-markdown”构建了一个DLL,名为markdown2html.dll。 The dll runs well in my test program, but failed in my qt application. 该dll在我的测试程序中运行良好,但在我的qt应用程序中失败。 Here's the code: 这是代码:

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;
}

}

The "works well" message has never shown, and I get the error message: “工作正常”消息从未显示,并且出现错误消息:

问题事件名称: 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

I have closed the DEP to my app as the site says: Problem Event Name: BEX, error message 如网站上所述,我已将DEP关闭到我的应用程序: 问题事件名称:BEX,错误消息

but it doesn't work. 但这不起作用。

Finally, I found the point that the default compiler of my Qt creator is mingw, but the dll is compiled with VC. 最后,我发现Qt创建者的默认编译器是mingw,但是dll是使用VC编译的。 There should be some diference between these two compiler and the std::string (in my case, "helloworld") cannot passed to the function in DLL correctly. 这两个编译器之间应该存在一些区别,并且std :: string(在我的情况下为“ helloworld”)无法正确传递给DLL中的函数。

So my solution is compiling all codes with the same compiler. 因此,我的解决方案是使用同一编译器编译所有代码。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM