Visual C++: Library Pragma

I find myself having to indicate the libraries I want linked in every time I do this. I found a neat (non-portable) trick in Visual Studio to do this.

Use the #pragma comment(lib, "libfile") [1] preprocessor directive to hint your compiler/linker to include these library files for linking. For example:

// Link cg libraries
#pragma comment(lib, "cg.lib")
#pragma comment(lib, "cggl.lib")

[1] msdn.microsoft.com/library/en-us/vclang/html/_predir_comment.asp

(via Adding MSDEV Libraries)

2 thoughts on “Visual C++: Library Pragma

  1. Hi, I’m just wondering is there any way to redirect these pragma messages to a different visual studio window than the output window?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.