Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kish

#pragma comment

This topic is 5991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to add new lib to my vc++ project. the library is placed in my computer under: c:\fmodApi\api\lib\fmodvc.lib I can do it by going to project->setting->link->... but I want to declare the lib in my code itself, so I''ll know what are the libraries that I use without having to check in the project setting every time. I tried to add the following line: #pragma comment( lib, "c:\fmodApi\api\lib\fmodvc.lib" ) but I get errors and warnings during the compilation/linking. Could anyone tell me how to do it properly ?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You must use double slashes, not single ones. change your pragma code to this:
#pragma comment (lib, "C:\\Path\\library.lib"

It should work.

Share this post


Link to post
Share on other sites
compilation warning:
warning C4129: ''l'' : unrecognized character escape sequence

linking errors:
LINK : fatal error LNK1104: cannot open file "c:.lib"
Error executing link.exe.


and: \\ does''nt work

Share this post


Link to post
Share on other sites
Anonymous Poster, Indirectx thanks !!!!!

#pragma comment( lib, "c:\\fmodApi\\api\\lib\\fmodvc.lib" )
works !!!!!!!!!!!!!!!!!!!!!!!!!!!!


you r god.

Share this post


Link to post
Share on other sites
Just to provide you an inside into why it works.

The single backslash \ works in C (and in many other languages as well) as an escape character which has to be followed by a second character to represent certain special characters like a tab (\t), a newline (\n) or a carriage return (\r). If you want just a normal backslash, you have to use the escape sequence \\ (two backslashes) because otherwise, the compiler will only see the escape character.

You may also use a single slash in the opposite direction, namely /. That will work for every path specification just as \\ does.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!