1

I have two projects in my C++ MSVC solution:

  1. A static library project

  2. A .exe project that has a reference to the Project #1 (the static library project)

  • Project #1 has additional include directories, C:/addincdir .
  • Project #1's header file, p1header.h includes the header hd.h from C:/addincdir.
  • Project #2 includes p1header.h .

But when I build the solution, I get an error: Project #2 cannot open include file hd.h (cannot find/locate the header file.) I know the solution is to add C:/addincdir to Project #2's additional include directories.

But is there a way for MSVC to automatically add referenced project's additional include directories? Or is there some kind of macro like $(Project1additionalincludedirectories) that includes Project #1's additional include directories and I can add this variable to Project #2's additional include directories?

It just wouldn't be practical to copy-paste every additional include directory from Project #1 to Project #2.

Robert Andrzejuk
  • 5,076
  • 2
  • 22
  • 31
Gabor Szita
  • 319
  • 4
  • 13

2 Answers2

0

No. There is no way to automatically add the folders.

(step 5 in Walkthrough: Create and use a static library - Use the functionality from the static library in the app)

To include a header file (listed in the additional include folders) you need to use <... >

#include <header.h++>
Robert Andrzejuk
  • 5,076
  • 2
  • 22
  • 31
-1

You can use an environmental variable such as using MORE_INC_DIR and set it to C:/addincdir1;C:/addincdir2;C:/addincdir3; and put $(MORE_INC_DIR) in the additional include directories of both projects.

E_net4
  • 27,810
  • 13
  • 101
  • 139
stackoverblown
  • 734
  • 5
  • 10