c++cwinapidia-sdk

Including dia2.h fails with C1083: Cannot open include file


The documentation for the DIA SDK claims that the header file is located at include\dia2.h. However, the following program fails to compile:

#include <include\dia2.h>

int main() {}

The full error diagnostic is

error C1083: Cannot open include file: 'include\dia2.h': No such file or directory

What's the issue and how do I solve it?


Solution

  • The DIA SDK isn't part of the platform SDK. Its artifacts aren't immediately available and must be explicitly introduced into the build system, like any old library.

    For MSBuild-based systems, like Visual Studios, you'll want to navigate to "VC++ Directories" and add $(VSInstallDir)DIA SDK\include to "Include Directories", or add

      <IncludePath>$(VSInstallDir)DIA SDK\include;$(IncludePath)</IncludePath>
    

    to the respective items in the .vcxproj file. This has to be done for "All Configurations" and "All Platforms".

    When building from the command line, use the /I <dir> compiler option. From a Visual Studio Command Prompt, the following will successfully build an object file:

    cl /I "%VSINSTALLDIR%DIA SDK\include" main.cpp
    

    Doing the above and changing the code to

    #include "dia2.h"
    
    int main() {}
    

    successfully compiles. This is following what the Dia2dump sample does. The sample is installed into %VSINSTALLDIR%DIA SDK\Samples\DIA2Dump.