smarte
smarte

Reputation: 51

how to quickly debug C++ include file problems

Very often we encounter this kind of issues like below:

1>Compiling...
1>a.cpp
1>c:\apps\b.h(22) : fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory

Sometimes it could be tedious as there a many include files and even nested include files in a big project.

What is the best way to trace / which include file is the culprit(parent) that include the problematic include file?

The problem is it has nested include, so will need to spend some effort before able to tell which file actually include b.h.

Upvotes: 5

Views: 5041

Answers (2)

Christian.K
Christian.K

Reputation: 49280

Looks like you're on Windows (thus maybe using Microsoft C/C++ compiler). In that case you can use the /showIncludes Option. Also see this SO answer.

This allows you to "visually" see which header file includes which, giving you some more information.

Update: Apparently GCC has some similar options.

Upvotes: 4

duedl0r
duedl0r

Reputation: 9424

Autotools has this feature. You can check whether certain header files are present or not.. I'm sure other build tools have similar features...

Upvotes: 0

Related Questions