I am working in VS 2008 and have several C++ projects and want to build my own library to share across projects. The first project is called "Project 1".
I created the library as a separate Wi开发者_StackOverflown 32 project, and chose DLL. I added a reference in Project 1 to the library using "Add reference". I also added an "Additional reference search path". I added #include "Library.h" to the top of the cpp file for Project 1.
However, I am getting the error: fatal error C1083: Cannot open include file: 'Library.h': No such file or directory.
How do I do this?
Thanks!
In Visual C++'s terms, referencing a project does not add it to include search path (this is a paradigm shift from .NET). Because in C++, include
can do all sorts of things -- you can even #include <not_even_a_c_file.txt>
, for example.
Anyway, the quick solution for you is to also add the include path to Project 1. You can find it under Project Properties > C++ > General. You need to add the path to Project 2 under "Additional Include Directories".
If the projects are in separate folders, you may have you do something like:
#include "../libproject/Library.h"
精彩评论