How to make a .lib file when have a .dll file and a header file(有.dll文件和头文件时如何制作.lib文件)
问题描述
我正在尝试在 Visual Studio 中创建一个能够访问已存在的 .dll 文件的应用程序.我需要应用程序来调用例程.我也有一个已经存在的头文件.
I am trying to create an application in visual studio that will be able to access a .dll file that already exists. I need the application to call up routines. I also have a header file that already exists.
我一直在网上研究,发现我需要创建一个 .lib 文件.在这里查看类似问题时,我找到了一个链接:http://support.microsoft.com/kb/131313但是,我无法按照指示进行操作.
I have been researching on the internet and have found that I need to create a .lib file. Looking at similar questions on here I found a link: http://support.microsoft.com/kb/131313 I cannot however follow the directions.
链接中的信息说要制作一个 DEF 文件(我在别处读到这需要编译为同名的 DLL,但不确定该名称是什么,与 .dll 文件同名?).但我不明白第一个方向,即使用 DUMPBIN/EXPORTS".然后我需要存根"函数,然后处理 .OBJ 文件(我不知道这些文件是什么).
The information in the link says to make a DEF file ( I read elsewhere that this needs to be compiled as a DLL with the same name, but not sure what that name is, the same name as the .dll file?). But I do not understand the first direction, to 'Use DUMPBIN /EXPORTS'. I then need to 'stub out' functions, and then something to do with .OBJ files (I do not know what these files are).
是否有与上面的链接类似的易于遵循的分步说明?
Are there any step-by-step directions, similar to the link above, that are easy to follow?
推荐答案
您将需要 Microsoft Visual C++ 2010 Express(或任何其他 MSVC 命令行工具来源)和您的 DLL.
You're going to need Microsoft Visual C++ 2010 Express (or any other source of MSVC command line tools), and your DLL.
步骤:
dumpbin/EXPORTS yourfile.dll >yourfile.exports- 将所需函数的名称从
yourfile.exports粘贴到新的yourfile.def文件中.在此文件的顶部添加一行带有EXPORTS字样的行. - 从
VCin目录(lib.exe和其他编译工具所在的目录)运行以下命令.
dumpbin /EXPORTS yourfile.dll > yourfile.exports- Paste the names of the needed functions from
yourfile.exportsinto a newyourfile.deffile. Add a line with the wordEXPORTSat the top of this file. - Run the following commands from
VCindirectory (the one wherelib.exeand other compile tools reside).
vcvars32.bat
lib /def:yourfile.def /out:yourfile.lib
或用于 x64 构建
lib /def:yourfile.def /machine:x64 /out:yourfile64.lib
您应该生成两个文件:yourfile.lib 和 yourfile.exp
You should get two files generated: yourfile.lib and yourfile.exp
这篇关于有.dll文件和头文件时如何制作.lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有.dll文件和头文件时如何制作.lib文件
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
