该应用程序无法正确启动(0xc000007b)Visual Studio C ++ [英] The application was unable to start correctly (0xc000007b) Visual Studio C++

查看:3425
本文介绍了该应用程序无法正确启动(0xc000007b)Visual Studio C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的hello world c ++程序,它链接sqlite3.dll(64位版本)。



我已经将sqlite3.h和sqlite3.dll正确添加到各自的路径。这些项目编译为64位架构。汇编和链接很好。



当我尝试运行exe时,会出现问题。



我在这里看到许多建议使用依赖关系的人。我把截图放在这里:





I不了解为什么它会失败,因为sqlite3.dll在exe的文件夹中。如果我理解依赖性很强的Walker发现它。 arch列为x64。



源代码:

  #include< iostream> 
#includesqlite3.h

int main()
{
std :: cout<<< Hello world and all that<<的std :: ENDL;
sqlite3 * db;
char * zErrMsg = 0;
int rc;

rc = sqlite3_open(test.db,& db);

if(rc){
fprintf(stderr,can not open database:%s\\\
,sqlite3_errmsg(db));
exit(0);
} else {
fprintf(stderr,opened database successfully\\\
);
}
sqlite3_close(db);

return 0;
}

如果exe和dll都是64位,我也使用了以下工具: PE解构程序。而且他们都是64位。



编辑



我有自己编写sqlite3.dll,按照



https://www.sqlite.org/howtocompile.html



,并附带以下说明:



1)加载 vcvars32.bat amd64



2)然后我cd:

  C:\程序文件(x86)\Microsoft Visual Studio 10.0 \VC \bin \amd64 

3)并启动命令:

  cl sqlite3.c -link -dll -out:sqlite3.dll / MACHINE:x64 

我试过官方的sqlite3.dll + sqlite3.def(x64二进制)转换为sqlite3.lib与以下命令:编辑2



  lib /def:sqlite3.def /OUT:sqlite3.lib / MACHINE:x64 

没有运气,同样的错误。



编辑3



我把dll放在错误的文件夹(VS有一个奇怪的输出目录树与重复的名称)。现在,将官方 dll放在正确的文件夹中可以



我设法修复了我定制的dll,看到接受的答案。我拿了官方的sqlite3.def文件,并通过添加/ def开关修改了编译命令。鉴于def是针对较新版本的sqlite的事实,链接器对一些缺少的符号抱怨。我从sqlite3.def文件中删除了这些符号,并正确编译了dll文件,并且还生成了.lib和.exp文件。 (现在不需要lib命令,因为直接创建了lib文件)。将新的dll放在正确的文件夹中就像一个魅力



请不要将问题分类为重复。



谢谢

解决方案

正如在评论中所解释的,您需要从二进制文件下载DEF文件包:
https://www.sqlite.org /2015/sqlite-dll-win64-x64-3090100.zip



然后,您需要将其添加到 cl 编译命令: /DEF:sqlite3.def



现在,您的DLL将需要导出的条目表。


I have a simple hello world c++ program which links sqlite3.dll (64 bit version).

I have added sqlite3.h and sqlite3.dll correctly in the respective paths. The projects compiles for 64 bit architecture. The compilation and linking goes fine.

The problem arises when I try to run the exe.

I have seen many questions here that suggest to use dependency walker. I am putting the screenshot here:

I don't understands why it fails since the sqlite3.dll is in the exe's folder. And if I understand well dependency walker finds it. The arch column is x64 for all.

The source code:

#include <iostream>
#include "sqlite3.h"

int main() 
{ 
    std::cout<< "Hello world and all that" << std::endl; 
    sqlite3 *db;
    char *zErrMsg = 0;
    int rc;

    rc = sqlite3_open("test.db", &db);

    if( rc ){
        fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
        exit(0);
    }else{
        fprintf(stderr, "Opened database successfully\n");
    }
    sqlite3_close(db);

    return 0; 
}

I have also used the following utility if the exe and dll are both 64 bit: PE Deconstructor. And both of them result to be 64 bit.

EDIT

I have compiled sqlite3.dll by myself following the instructions in

https://www.sqlite.org/howtocompile.html

with the following instructions:

1) loaded vcvars32.bat amd64

2) then I cd in:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64

3) and launch the command:

cl sqlite3.c -link -dll -out:sqlite3.dll /MACHINE:x64 

EDIT 2

I tried the official sqlite3.dll + sqlite3.def (x64 binaries) converted to sqlite3.lib with the following command:

lib /def:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64

with no luck, same error.

EDIT 3

I was putting the dll in the wrong folder (VS has a strange output dir tree with duplicated names). Now putting the official dll in the correct folder it works.

I managed to fix also my custom built dll, see accepted answer. I took the official sqlite3.def file and modified the compile command by adding the /def switch. Given the fact that the def was for a newer version of sqlite the linker complained for some missing symbols. I removed those symbols from the sqlite3.def file and it compiled correctly the dll file and also produced .lib and .exp files. (There is no need for the lib command now as the lib file is created directly). Putting the new dll in the correct folder works like a charm.

Please don't classify question as duplicate.

Thanks

解决方案

So as explained in comments, you need to download the DEF file from binary package: https://www.sqlite.org/2015/sqlite-dll-win64-x64-3090100.zip

Then you need to add this to cl compilation command: /DEF:sqlite3.def

Now your DLL will have required entries in export table.

这篇关于该应用程序无法正确启动(0xc000007b)Visual Studio C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆