开发者

How to create a library and call the header files using < > instead of ""?

开发者 https://www.devze.com 2023-01-04 10:47 出处:网络
I\'ve been writing a library lately for my C++ computer class. I w开发者_JS百科ould like to put all my .lib and my header files inside a folder outside the project that\'s going to be calling the libr

I've been writing a library lately for my C++ computer class. I w开发者_JS百科ould 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


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.


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>.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号