# #pragma comment troubles

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

## Recommended Posts

I'm having a problem with linking some libraries using #pragma comment(lib,"") This works fine if my library is in my main project directory:
#pragma comment(lib,"luad.lib")

But if I create a new folder called lua in my project folder and try:
#pragma comment(lib,"lua\\luad.lib")

I get the LINK error "cannot open luad.lib". I tried an absolute path as well ie "C:\\my solution\\my project\\luad.lib" which also did not work.

##### Share on other sites
Try using forward slashes. dunno if that will really help or not but I've never had a problem with pragmas... also you can try adding the library path to visual studios paths.

the Studio paths are in Tools->Options->Projects->VC++ Directories

##### Share on other sites
Thats what I am trying to avoid, is having to manually add the library via the IDE options.

I *could* put all the external libraries I am using in the main project folder, but that just seems like a mess, especially if you have a large project.

Can't figure out why this doesn't work. Ugh.

##### Share on other sites
Does it work if you do:
#pragma comment(lib,"lua/luad.lib")

Toolmaker

##### Share on other sites
You only need a single backslash in preprocessor directives liek #pragma. Alternatively, use forward slashes. They'll work on UNIX systems too, and will prevent this sort of thing from popping up

##### Share on other sites
Quote:
 Original post by x_gamer_xThats what I am trying to avoid, is having to manually add the library via the IDE options.

The previous suggestion wasn't to add the specific library to the project. It meant to add the path to the IDE so that you could #pragma your lib in the code without the path. But then, is there any specific reason you want to avoid changing your project settings?

##### Share on other sites
The reason I am doing it this way is so that when I hand off my project to other teammembers and instructors they can open up the solution and compile right off the bat, without having to do the whole tools->options->projects deal for libraries I am using. Convience really.

##### Share on other sites
Quote:
 Original post by ToolmakerDoes it work if you do:#pragma comment(lib,"lua/luad.lib")Toolmaker

Nope. :(

##### Share on other sites
Quote:
 Original post by x_gamer_xThe reason I am doing it this way is so that when I hand off my project to other teammembers and instructors they can open up the solution and compile right off the bat, without having to do the whole tools->options->projects deal for libraries I am using. Convience really.

Using pragma tells the project to include the library, but it doesn't tell it where to look. That still needs to be set up in your build environment (in your case the IDE).

##### Share on other sites
Quote:
Original post by petewood
Quote:
 Original post by x_gamer_xThe reason I am doing it this way is so that when I hand off my project to other teammembers and instructors they can open up the solution and compile right off the bat, without having to do the whole tools->options->projects deal for libraries I am using. Convience really.

Using pragma tells the project to include the library, but it doesn't tell it where to look. That still needs to be set up in your build environment (in your case the IDE).

Yep, sounds like you might need to rethink your logistics a bit. If you are working on a project in a group there's a good chance the other teammembers should be building against the same environment, so that's really a non-issue.
Handing it in as an assignment is another matter though, and one which pretty much limits you to keeping all the headers and libs somewhere within your project directory. (As an instructor, I would expect zero installs or configuration to build a student project, lest the grade suffers.) Although, if you're using Visual Studio you can set additional lib and include directories in the actual project settings instead of the IDE, which is probably your best option for portability.

1. 1
2. 2
Rutin
22
3. 3
4. 4
5. 5
frob
12

• 9
• 17
• 9
• 31
• 16
• ### Forum Statistics

• Total Topics
632617
• Total Posts
3007451

×