GCC compile debug: print include files and compile stage info.

Sample code:

#include <stdio.h>
#include <stdlib.h>

extern void foo() __attribute__((weak));
int main() {
  if (foo) foo();
  printf("this is a test\n");
}

Compile command:

gcc -H -v sample.c 

Compile options:

-H tells you that the right include files used.
Official document:

Print the name of each header file used, in addition to other normal
activities. Each name is indented to show how deep in the ‘#include’
stack it is. Precompiled header files are also printed, even if they
are found to be invalid; an invalid precompiled header file is printed
with ‘…x’ and a valid one with ‘…!’ .

-v (or even maybe -Wl,-v) tells you that the right libraries used.
Official document:

Print (on standard error output) the commands executed to run the
stages of compilation. Also print the version number of the compiler
driver program and of the preprocessor and the compiler proper.

Sample output:

…………………….
/usr/include/x86_64-linux-gnu/bits/waitflags.h
/usr/include/x86_64-linux-gnu/bits/waitstatus.h
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h
/usr/include/x86_64-linux-gnu/gnu/stubs.h COLLECT_GCC_OPTIONS=’-o’
‘hello’ ‘-H’ ‘-v’ ‘-mtune=generic’ ‘-march=x86-64’ as -v –64 -o
/tmp/ccwD1DYA.o /tmp/cc8CU0IV.s GNU assembler version 2.24
(x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/lib/:./:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
…………..

Ref:

  1. https://gcc.gnu.org/onlinedocs/
  2. http://stackoverflow.com/questions/28563263/c-compiling-errors-on-debian
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值