Using a static library when I only have the .lib and .h files

It seems that static libraries must always be compiled with the current project and the source code for them must be available. In that case, what's the difference between creating a library and just referencing the project

In 2005, I was unable to 'link' (by which I mean refernce) to a static library for which I only had the .lib and .h files. Is there some way to do this

btw, the library I wish to use depends on other libraries.



Answer this question

Using a static library when I only have the .lib and .h files

  • Julian V

    you don't need to set any "references". #include the header file into your source code and include the .lib file in the linker's command line (in the "additional dependencies" property if you are using the IDE)

    josh

    VC++ project system developer



  • Syndrake

    You only need the header files and the libs to use a static library. But, the static lib must be compiled/linked using settings that are compatible with the main application. For example, if your exe uses static CRT, then so must the static lib. You may also need to have libs for each compiler - a static lib compiled with VC6 may not work with an app compiled using VC8.

  • Jeffrey van Gogh_MS

    ah, this is not a library file that you are trying to use, but a dll. see

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/vccore/html/vcconImportingExporting.asp

    for help on importing and exporting symbols from dlls

    hth,

    josh

    vc++ project system developer



  • chossy

    I tried doing just that, and the linker can't find the functions in the library

    Here's the VERY simple VS2005 solution that shows what I tried:

    www.cs.columbia.edu/~aner/testdll.zip

    The error I got is in a comment in main.cpp

    Thanks,

    Aner


  • Derek Li

    How do you make use of .lib and .h files (compiled correctly for the current project), without having the .cpp files

    The only documentation I have found says you have to set References, which means you have to compile the library in the same solution.

    Thanks


  • Using a static library when I only have the .lib and .h files