Creating .lib File from .dll and Header in Visual Studio
To access existing .dll routines in your Visual Studio application, you need to create a .lib file.
Step-by-Step Instructions:
-
Use the DUMPBIN tool:
- Open a command prompt as administrator.
- Navigate to the directory containing your .dll file.
- Enter the following command: DUMPBIN /EXPORTS "yourfile.dll" > "yourfile.exports"
- This will generate a file called "yourfile.exports" containing the exported functions in the .dll.
-
Create a .def file:
- Open a text editor and create a new file named "yourfile.def".
- At the top of the file, add the line: EXPORTS
- Copy the exported function names from "yourfile.exports" and paste them into the .def file.
-
Build the .lib file:
- Open a Visual Studio command prompt as administrator.
- Navigate to the Visual C bin directory (e.g., C:Program Files (x86)Microsoft Visual Studio 14.0VCbin).
- If you need a 64-bit .lib file, use: lib /def:"yourfile.def" /machine:x64 /out:"yourfile64.lib"
- Otherwise, use: lib /def:"yourfile.def" /out:"yourfile.lib"
- This will create a .lib file named "yourfile.lib" or "yourfile64.lib" containing the necessary import information.
The above is the detailed content of How to Create a .lib File from a .dll and Header in Visual Studio?. For more information, please follow other related articles on the PHP Chinese website!