Archived

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

#pragma comment

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

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 ?

What errors?

Try \\.

Share on other sites
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 on other sites
compilation warning:
warning C4129: ''l'' : unrecognized character escape sequence

LINK : fatal error LNK1104: cannot open file "c:.lib"

and: \\ does''nt work

Share on other sites
Anonymous Poster, Indirectx thanks !!!!!

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

you r god.

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 on other sites
Many thanks Origin

It was very informative

1. 1
2. 2
JoeJ
20
3. 3
frob
16
4. 4
5. 5

• 10
• 10
• 11
• 13
• 9
• Forum Statistics

• Total Topics
632196
• Total Posts
3004718

×