how to make an import library in vs2008

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teamrip
    New Member
    • Mar 2010
    • 1

    how to make an import library in vs2008

    a requirement was sent to me below:

    API should be in the form of static library. company xxx will link the library into a third party application to prevent any possible exposure of the code(dll)

    could they mean an import library? An import library is a library that automates the process of loading and using a dynamic library. On Windows, this is typically done via a small static library (.lib) of the same name as the dynamic library (.dll). The static library is linked into the program at compile time, and then the functionality of the dynamic library can effectively be used as if it were a static library.

    this might be what they might be eluding to.....I am not sure how to make this in vs2008 .

    Additional facts: I have a static lib that i use in my current application. Now, I have to convert my app that uses that static lib into an import lib so that they can use a third party prog to access the API's they providede me which in turn will use that static lib i am using.

    I hope I am clearly explaining this. I am just not sure how to go about it in vs2008. I am looking for specific steps to do this. I already have the coding done. Just need to convert it into the form they are asking and I have to provide the API they want. Other than that then I need to create a test prog which will act as that third party prog so I can make sure my import library works. Thus, if i can just make the import library then I can do the other stuff to test it.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I don't see how a DLL exposes the code.

    What the decision should be based on is: Does the link occur at run-time or compile time? If run-time, then use a DLL. If compile time then use a static library.

    A DLL requires a LoadLibrary call followed by a GetProcAddress followed by a type-cast of the FARPROC returned by GetProcAddress to a function pointer of the correct prototype for the function bein called.

    However, you can still use a DLL as a static library if the DLL interface functions can be imported. That is, the DLL must support __dllimport.

    In this case, a .lib is created by Visual Studio for each function in the dll that supports __dllimport. In that lib is a function of the correct name an prototype (as would be in your function pointer) and inside that funciton is called LoadLibrary and GetProcAddress.

    However, the DLL is still run-time linked.

    If you are uncertain on how to create libraries, then create a WIN32 project and when the wizard appears, do not click finish. Instead, click Application settings. On that dialog are check boxes for static or dynamic library. Make your selection and then click finish.

    Comment

    Working...