C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-19-2009, 04:53 PM   #1
Registered User
 
Join Date: Apr 2009
Posts: 34
What's an import library?

Hi,

I think I understand the concept of static(.lib) vs. dynamic(.dll) libraries, but I don't think I fully understand the various kinds of .lib libraries.

1) I'm using MSBUILD to build a .dll library, and when I compile my codes, it creates .obj, .lib, and .dll files. So I understand what .obj and .dll files are, but why is the .lib library created? Is this library an import library? if so, where is it used? and which information can it contain?

2) Also I believe that there are MSBUILD macros like DLLLIBOBJECTS that we use to add extra objects to an import library. What purpose would it serve to add additional object files?

3) I built a mylib.lib file using C++ codes. This code uses Windows Crypto APIs. I also have another .dll project that links against this .lib file. Attempting to compile the .dll project without linking Crypt32.lib against it (using TARGETLIBS macro) resulted in unresolved symbol error (symbols representing the APIs that I used in the .lib source files). Because I didn't want to put burden on every project that uses mylib.lib of having to link against the crypt32.lib, I wanted to link crypt32.lib to mylib.lib, so that all such projects could simply link against one library mylib.lib, instead of two. But the same unresolved symbol error resulted when I tried to use this new mylib.lib. (the new mylib.lib was compiled after adding TARGETLIBS=$(LIBRARY_PATH)\Crypt32.lib in "sources" file of mylib.lib project). So is it the case that a .lib can't be linked within another .lib file?

4) At the bottom of the APIs' corresponding MSND pages, the following usage information is available.
Quote:
Header Wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll
Is Crypt32.lib an import library in this case?

Thanks!

Last edited by chiefmonkey; 06-19-2009 at 04:57 PM.
chiefmonkey is offline   Reply With Quote
Old 06-19-2009, 05:00 PM   #2
Registered User
 
valaris's Avatar
 
Join Date: Jun 2008
Location: RING 0
Posts: 462
The compiler still requires the definitions of exported functions. These definitions will have special compiler instructions however to let it know the rest of the definition will come at runtime.
valaris is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
import from python library zoupi C Programming 2 05-11-2009 10:09 AM
dllimport George2 C++ Programming 15 02-23-2008 04:35 AM
DLL generated but related import library is missing? George2 C Programming 0 08-18-2006 12:13 AM
very weird .h problem royuco77 C++ Programming 1 09-11-2005 07:55 AM


All times are GMT -6. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22