C++ Visual Studio: linking using pragma comment

后端 未结 3 1847
南旧
南旧 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:26

    Classic example - linking against different versions of the library:

    #if CURRENT_VERSION >= 10
         #pragma comment(lib, "thirdPartyLibV2.0.lib")
    #else //version < 10
         #pragma comment(lib, "thirdPartyLibV1.0.lib")
    #endif
    

提交回复
热议问题