当有.dll文件和头文件时,如何创建一个.lib文件 [英] How to make a .lib file when have a .dll file and a header file

查看:169
本文介绍了当有.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).

推荐答案

您将需要 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.

步骤:


  1. dumpbin / EXPORTS yourfile。 dll> yourfile.exports

  2. 将所需功能的名称从 yourfile.exports 粘贴到新的code> yourfile.def 文件。在这个文件顶部添加一个单词 EXPORTS 的行。

  3. VC运行以下命令\bin 目录(其中 lib.exe 和其他编译工具所在的目录)。

  1. dumpbin /EXPORTS yourfile.dll > yourfile.exports
  2. Paste the names of the needed functions from yourfile.exports into a new yourfile.def file. Add a line with the word EXPORTS at the top of this file.
  3. Run the following commands from VC\bin directory (the one where lib.exe and other compile tools reside).

 vcvars32.bat

 lib /def:yourfile.def /out:yourfile.lib

你应该得到两个生成的文件: yourfile.lib yourfile.exp

You should get two files generated: yourfile.lib and yourfile.exp

这篇关于当有.dll文件和头文件时,如何创建一个.lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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