静态链接到 lib 并仍然请求 DLL
使用 Visual Studio 2008,我有一个库的 .H
和 .LIB
文件。 我编写了一个程序并通过项目属性引用了 LIB。 它编译得很好,但是当它运行时,它要求安装 DLL。 如果 DLL 与 EXE
位于同一目录中,它就可以工作,但是,如果我有 LIB
,这是否已经意味着这些函数已静态链接到我的程序?
Using visual studio 2008, I have an .H
and a .LIB
file of a library.
I wrote a program and referenced the LIB via the project properties.
It compiles fine, but when it runs, it asks for the DLL to be installed.
If the DLL is in the same dir as the EXE
it works but, if I have the LIB
, doesn't it already mean the functions are statically linked to my program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
并非所有
lib
文件都是静态库。有些是导入库,很可能就是您链接的库。如果您的
lib
文件比其相应的dll
文件小得多,则明确表明它是导入库。Not all
lib
files are static libraries. Some are import libraries, and chances are, that's what you linked with.If your
lib
file is much smaller than its correspondingdll
file, that's a sure sign that it's an import library.让您的程序使用 DLL 需要导入库。它是一个扩展名为 .lib 的文件,就像静态 .lib 一样。但它很小,只包含DLL导出的函数列表。链接器需要它才能将 DLL 的名称嵌入导入表中。您可以通过在 .exe 上运行 Dumpbin.exe /imports 来亲自查看这一点
Letting your program use a DLL requires an import library. It is a file with the .lib extension, just like a static .lib. But it is very small, it only contains a list of the functions that are exported by the DLL. The linker needs this so it can embed the name of the DLL in the import table. You can see this for yourself by running Dumpbin.exe /imports on your .exe