Visual Studio: What exactly are lib files (used for)?

前端 未结 3 1065
谎友^
谎友^ 2021-01-13 09:43

I\'m learning C++ and came across those *.lib files that are obviously used by the linker. I had to set some additional dependencies for OpenGL.

  • What exactly a
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 10:35

    In simple terms, yes - .lib files are just a collection of .obj files.

    There is a slight complication on Windows that you can have two classes of lib files.
    Static lib files essentially contain a collection of .obj and are linked with your program to provide all the functions inside the .lib. They are mainly a convenience to save you having as many files to deal with.

    There are also stub .lib which provide just the definitions of functions which are contained in a .dll file. The .lib file is used at compile time to tell the compiler what to expect from the function, but the code is loaded at run time from the dll.

提交回复
热议问题