tags:

views:

61

answers:

3

Hello,

I've been writing a library lately for my C++ computer class. I would like to put all my .lib and my header files inside a folder outside the project that's going to be calling the library. How can I call the library header files using the < > operators instead of the " "?

I'm using visual studio [specifically VS03]

Thanks, Y_Y

+3  A: 

To include files in a separate directory from the directory where your source files are, you must add the directory with the headers to your "Additional Include Directories" property in the "C\C++, General" property page for your project. Then you can include the headers with either <> or "".

See http://msdn.microsoft.com/en-us/library/36k2cdd4(VS.71).aspx

The quote form just searches in the "." directory first.

bshields
+1  A: 

include <file>

This variant is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the -I option.

include "file"

This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then the same directories used for <file>.

Romain Hippeau
A: 

If the directory where the header files exist is in the "C-C++/General/Additional Include Directories" configuration parameter for the project. Once that's done, you can use wither <> or "" to include the header (in MSVC, the difference is that when using "" the compiler will look in the current directory for the header before looking in the various configured paths).

To have your project link to your library, you'll need to include the library in the "Linker/General/Input" project setting. You can include the path information there, or just the filename and include the directory where it's located in the "Linker/General/Additional Library Directories" setting.

Michael Burr