Reputation: 271
When I am using a non-standard library in C++ I have to add the library name in linker-->input-->additional dependencies . But the alternative is to write
#pragma comment(lib , "library name")
Are these two methods completely the same?
Upvotes: 5
Views: 739
Reputation: 17183
They are not.
The said pragma adds a defaultlib. The option a mandatory lib to the linker line.
The latter is processed no matter what, and you get error if it is missing. The default lib is ignored silently if not found. And using options "ignore default libs" or "ignore specific default lib" can be used to dismiss its use even if it is present.
Upvotes: 5
Reputation: 1905
These are two ways of doing the same thing. i.e. the compiler telling the linker which libs to look for. #pragma comment has other functions too like adding data like compiler info or any other meta data to the object file.
#pragma comment is VC++ specific.
Upvotes: 0