#pragma comment troubles

Started by
9 comments, last by nohbdy 19 years, 6 months ago
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.
-------------------------Rayoom Sledge Hammer Productions - Programmer
Advertisement
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
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.
-------------------------Rayoom Sledge Hammer Productions - Programmer
Does it work if you do:
#pragma comment(lib,"lua/luad.lib")


Toolmaker

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
Quote:Original post by x_gamer_x
Thats 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?
I set the clouds in motion, turn up light and sound...Activate the window, and watch the world go 'round
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.
-------------------------Rayoom Sledge Hammer Productions - Programmer
Quote:Original post by Toolmaker
Does it work if you do:
#pragma comment(lib,"lua/luad.lib")


Toolmaker


Nope. :(
-------------------------Rayoom Sledge Hammer Productions - Programmer
Quote:Original post by x_gamer_x
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.


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).
Quote:Original post by petewood
Quote:Original post by x_gamer_x
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.


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.
I set the clouds in motion, turn up light and sound...Activate the window, and watch the world go 'round

This topic is closed to new replies.

Advertisement