5

I am having two projects in one solution called SOL, using Visual Studio: project 1 and project 2

In each of projects: I am having some headers and cpp files.

In project 2, I want to use a header existing in project 1:

#include "proj1.h"

I am having an error which states that the file doesn't exist:

 Error  2   error C1083: Cannot open include file: 'proj1.h': No such file or directory C:\Users\...\Visual Studio 2010\Projects\SOL\proj2.cpp  28
MelMed
  • 1,702
  • 5
  • 17
  • 25
  • possible duplicate of [visual c++: #include files from other projects in the same solution](http://stackoverflow.com/questions/601268/visual-c-include-files-from-other-projects-in-the-same-solution) – TobiMcNamobi Sep 30 '13 at 08:58

1 Answers1

3

I'm using VS 2012 but AFAIK for this subject this is nearly the same.

  • Open the project properties page of project 2. Right-click on project 2 in the solution explorer and select "Properties".
  • In the C/C++ section select "General".
  • Find the line "Additional Include Directories" and add "$(SolutionDir)project 1". This is a semicolon separated list but you can as well choose to edit this field, then you get a list view.
TobiMcNamobi
  • 4,687
  • 3
  • 33
  • 52
  • This only works if the other project is in a subdirectory of the solution, which is not generally the case. – Sven Feb 29 '16 at 09:44
  • 5
    and it only links the header files so you will end up in unresolved external dependencies if you have any cpp file in the other project... – Stefan Reinhardt May 28 '18 at 14:55