Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does visual studio create a .LIB along with the .DLL?

I have a project "Logger" wherein the configuration type is .dll.

"Logger" uses "libconfig" (an open source config parser). Currently, I have a separate project for "libconfig" and its configuration type is .lib

I added "libconfig" to Logger's frameworks and references setting with:

  • link library depedencies = true
  • use library dependency inputs = false

In Logger's linker command line, i see: /IMPLIB: "path\to\Logger.lib"

My question is: Why does Logger.lib need to be created? I see /OUT = "path\to\Logger.dll", but I'm trying to get a hang of visual studio's build process.

From M$'s IMPLIB doc, I see its part of the LINK process. I still don't get it.

Edit: I didn't mention how the Logger DLL was to be used. My application would be loading it at run-time (since this functionality is only required for specific cmd line args)

like image 563
Raja Avatar asked Sep 27 '13 01:09

Raja


People also ask

What is .LIB file in Visual Studio?

In this article The Microsoft Library Manager (LIB.exe) creates and manages a library of Common Object File Format (COFF) object files. LIB can also be used to create export files and import libraries to reference exported definitions. Note. You can start this tool only from the Visual Studio command prompt.

Can I use a DLL without lib?

The only way to access a bare DLL without a . lib file is to load the DLL explicitly with LoadLibrary() , get pointers to the exported functions you want to access with GetProcAddress() , and then cast those pointers to the proper function signature.

What is the use of .LIB file?

LIB (lib.exe) creates standard libraries, import libraries, and export files you can use with LINK when building a program.

Is DLL same as lib?

LIB vs DLL LIB is a static library where functions and procedures can be placed and called as the application is being compiled. A DLL or Dynamic Link Library does the same function but is dynamic in a sense that the application can call these libraries during run-time and not during the compilation.


1 Answers

An exe that uses your logger.dll is going to need to link to logger.lib. Without the lib the exe cannot be built. The lib contains stub functions that satisfy the calls made by exe code. (At runtime the stubs transfer the calls into the DLL.)

like image 123
ScottMcP-MVP Avatar answered Oct 05 '22 23:10

ScottMcP-MVP