IInspectable
IInspectable

Reputation: 51355

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?

Upvotes: 0

Views: 320

Answers (1)

IInspectable
IInspectable

Reputation: 51355

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.

Upvotes: 1

Related Questions