C++ Visual Studio: linking using pragma comment

后端 未结 3 1845
南旧
南旧 2020-12-18 18:58

I came across a piece of code which uses #pragma comment(lib, \"libraryname\").

Why this type of usage as opposed to just linking the library from the properties men

3条回答
  •  天涯浪人
    2020-12-18 19:17

    The library writer can place a #pragma comment(lib, ...) command in the public header (.h) file. In this case, the client doesn't need to add this library to the linker dependencies list. By including an h-file in the program, the client is automatically linked to the required library.

提交回复
热议问题