How would I include a lib that is in a different folder than vc7? e.g. the lib is in C:\abc\Lib. Is it possible to set something like a PATH value in C++ to allow it to look for libraries in specific places? What is the standard practice?
Thanks.
This is a discussion on importing libraries from elsewhere within the C++ Programming forums, part of the General Programming Boards category; How would I include a lib that is in a different folder than vc7? e.g. the lib is in C:\abc\Lib. ...
How would I include a lib that is in a different folder than vc7? e.g. the lib is in C:\abc\Lib. Is it possible to set something like a PATH value in C++ to allow it to look for libraries in specific places? What is the standard practice?
Thanks.
in which case, use something along the lines ofNote the double-backslashes. Backslash is a special character in C++ string literals for using 'escape sequences' - The double backslash is the escape sequence for the backslash itselfCode:#include "C:\\abc\\Lib\\my_header.h"
If you don't like that, you can usually use forward-slash instead:Code:#include "C:/abc/Lib/my_header.h"
Edit - if your header files are in a sub-folder of the current project, then you don't need to specify the full path, just the subfolder and filename
Last edited by Bench82; 01-04-2007 at 08:10 PM.
would it make a difference if the path to the library is set in the user environment variables (win xp)?
In the project settings you can add
Project Properties/Configuration Properties/C++/General/Additional Include directories
The new path where the h-files will be looked for
Or You can open
Tools/Options/Projects adn Solutions/VC++ Directories
And add some directories to the Include files list
This will affect all projects
If I have eight hours for cutting wood, I spend six sharpening my axe.
You should never use absolute paths inside include statements. It makes it much harder to port the code to even another directory on the same machine, nevermind elsewhere.
Use Vart's suggestion of setting search paths in the IDE
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
The escapes are not processed in preprocessor directives.Originally Posted by Bench82
it should be
But still forward slashes are a lot better. Best solution is definately vart's way to add a -I compiler switchCode:#include "C:\abc\Lib\my_header.h"
Kurt