Lib.exe, Visual Studio, creating .lib files from dll and def files

I am new to windows and visual studio. I have to compile code written in C ++. It uses different libraries. I found DLL files for these libraries. I can compile the source without any problems, but there are problems with the links. I do not know how to link DLL files. I realized that for this I need .lib files. But some of the required libraries do not contain any lib files. There are only dll files and diff files. How can I generate the required lib files using Visual Studio 2010? I can not find the program called lib.exe. Thanks.

+8
dll visual-studio-2010
source share
3 answers

You really need lib.exe to turn the .def file into the .lib file that the linker needs. It is stored by default in the vc \ bin directory of the visual studio directory, C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \ lib.exe. The easiest way is to use the Visual Studio Command Prompt, you will find it in the Start menu, Microsoft Visual Studio 2010, Visual Studio Tools.

Then run lib.exe with the /def:foo.def option to create .lib. Follow the supplier’s instructions, if provided. And feel free to contact them for support.

+14
source share

This requires a lot of work, and is usually easier for google for the source and / or libs for the DLL you need, as it is a good idea to compile both the libraries and your program with the same compiler (simplifies deployment, so you do not depend on multiple vc sessions).

You can use this guide to create .lib files: http://support.microsoft.com/kb/131313

This is a time-consuming process and also a lot of debugging (depending on the size of the DLL, as well as the complexity of the dll interfaces)

Depending on your platform, the location is usually:

  • Windows 7 32-bit with 32-bit VS2010:

    C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin \

  • Windows 7 64-bit with 64-bit VS2010:

    C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ bin`

  • Windows 7 64-bit with 32-bit VS2010:

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

However, if you run the Visual Studio command prompt, it should be in your path. (See the Visual Studio Tools section in your start menu)

+2
source share

If you go to the project properties for the DLL and select the Linker → Advanced check box, the entry "Import Library" appears. You may need to install this to generate the lib file when creating the DLL, or if it is already installed, it should point you to the location of the lib file.

If you create an entire project using Visual Studio 2010, adding dependent libraries in the "General Properties" section of the project should automatically launch the necessary link operators.

+2
source share

All Articles