Include file dependencies in Visual Studio 2017 C++ projects

Amir Ansari 20 Reputation points
2023-03-13T01:03:01.5966667+00:00

I am using Visual Studio 2017 and would like to understand include file dependency propagation.

In my solution file, I have C++ projects A, B, C. A has 'Additional Include Directories' set for external libraries, 'Additional Library Directories' for libraries, and specifies external.lib in 'External Dependencies'. Project B needs to use A, and Project C needs to use Project B. What is the recommended way to setup these project dependencies? I can manually setup everything through 'Additional Include Directories' and 'External Dependencies', but I am looking for a way to transitively propagate these dependencies.

Related to this, do I need to add Project A in 'Additional Include Directories' of Project B, and A.lib as an 'External Dependency'?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,888 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,637 questions
0 comments No comments
{count} votes

Accepted answer
  1. YujianYao-MSFT 4,281 Reputation points Microsoft Vendor
    2023-03-13T02:50:38.0766667+00:00

    Hi Amir Ansari,

    There is no transitive dependency in the static library. We assume that lib2 links lib1. At this time, lib2 can get the content in lib1, and then there is a project that needs to use the content in lib1 and lib2., you couldn't just link lib2, you need to link both libraries and add dependencies.

    If there are too many static libraries that need to be linked, this is a very tedious operation. If this happens, I suggest you merge the contents of the library or use a dynamic library.

    Best regards,

    Elya


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful