What's an import library?

This is a discussion on What's an import library? within the C++ Programming forums, part of the General Programming Boards category; Hi, I think I understand the concept of static(.lib) vs. dynamic(.dll) libraries, but I don't think I fully understand the ...

  1. #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.
    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 05:57 PM.

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. import from python library
    By zoupi in forum C Programming
    Replies: 2
    Last Post: 05-11-2009, 11:09 AM
  2. dllimport
    By George2 in forum C++ Programming
    Replies: 15
    Last Post: 02-23-2008, 04:35 AM
  3. DLL generated but related import library is missing?
    By George2 in forum C Programming
    Replies: 0
    Last Post: 08-18-2006, 01:13 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 08:55 AM

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