简体   繁体   中英

How do I find out which header g++ includes?

I'm compiling an open-source project which fails saying that the sincos function is not declared. When I look in math.h , the declaration is there. I added a warning to the very top of math.h to see if it gets included (a warning would be printed if it does), and it actually never gets printed when I compile the code. Hence, I assume that it may get included from somewhere other than /usr/include/math.h .

The problem is that it's a giant codebase and is quite impenetrable as far as tracing include directories and such by hand.

Is there a way I can tell g++ to print full paths of all includes that it resolves?

You can use the -E option to run the preprocessor only. This will produce the source code after preprocessing with all the header files, which is likely to be very long.

Instead you can generate a makefile to show the dependencies. If you use -E -M , you should see a list of all include files the file depends on.

In addition to g++ -E -C , I find the -v argument useful for this situation. It will give you all of the default search paths/sysrooty stuff, as well as any default internal arguments passed to the sub-tools.

Additionally, this command will tell you if gcc is attempting to use a default include path that doesn't exist, which is a common issue in incorrectly configured gcc toolchains.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM