tags:

views:

176

answers:

5

It's pointed out by this answer:

http://stackoverflow.com/questions/2532280/failed-to-link-mysql5-1-39-bin-libmysql-dll-in-a-c-project/2532382#2532382

But I don't understand why,.dll is essentially the same as .lib except for there is only one copy of it used by different processes.

Does it have anything to do with the IDE?I'm using visual c++ 2008 express

UPDATE

Anyone know a free tool to convert .dll into .lib in windows?

+5  A: 

You are wrong on two counts. Firstly, DLLs and LIBs (static libraries) are very different beasts. The LIB you are talking about (I think) is the export library, which is simply a list of names in the DLL. This library is typically produced when the DLL is compiled and is shipped with the DLL if the DLL is intended to be linked to by other developers.

To use a DLL with a modern IDE (I don't use VS) you typically include the matching .LIB (export library) in the project. At run-time you must make sure the DLL is available to your program - the simplest way to do this is to put the DLL in the same directory as the executable.

And secondly, DLLs can be used with C++.

anon
If I have a .lib,I want bother around the dll any more..
Mask
@Mask That makes no sense.
anon
@Neil: He's mixed up between link libraries and full static libraries. “Helpfully” they have the same extension.
Donal Fellows
All I have by hand is `libmySQL.dll` and no `.lib`,so the only way out seems to be a tool that can convert the dll into lib.Is there a free one that actually works?
Mask
@Mask: If you don't have an import library (the `.lib` that goes with the DLL), you need to use `LoadLibrary`, `GetProcAddress`, and friends to load the library (http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx) and call its interface functions.
James McNellis
A: 

DLL are specific windows executables which load on runtime. Their equivalent in Linux is the *.so .
If you want to understand what's the difference between a DLL and a static lib see here.

the_drow
Is there a reliable tool to convert dll to lib?
Mask
no, they have different entry points. in fact a static lib is static and it's sort of an "attachment" to your main exe, so it's entry point is your exe.The DLL has a separate entry point.
the_drow
A: 

Main reason has probably something to do with dll-file being an output of the linker (link.exe). This command line utility doesnt know how to read dlls, only how to write them.

Actually sometimes .lib-files contain more than a list of functions. For example libpng.lib works as a standalone file, without any dll file.

AareP
There are at least two types of .lib files export libraries and static libraries.
anon
A: 

In order to use a DLL in C/C++ you need to link with what is called an import lib. This is a small .lib that contains the names/ordinals the DLL exports in a format that the linker understands. Once this has been linked in, the resulting binary will be able to use the DLL. If you do not have the appropriate import lib, your C/C++ compiler should come with a tool to generate one from the DLL.

Ignacio Vazquez-Abrams
A: 

You can use the following analogy to understand the difference between a dll and a lib file.

the dll is like the source .cpp file while the lib is the header .h file.

While this is not exactly true, the DLL holds the executable code while the LIB file tells the linker how to glue the code together.

It is also possible (in some cases) to generate the lib from the dll. Basically, all you need to know to call a function is the function entry point in the dll, the number of parameters and the size of each parameters. Sending relevant information is then your own problem.

Eric
Someone has asked about this but seems there isn't a free and working tool yet:http://stackoverflow.com/questions/1536557/converting-a-windows-dll-to-lib-for-c-visual-studio-2008
Mask