hpux下g++编译使用libunwind,_UNW_STACK_TRACE未定义问题

  • 直接引用头文件#include 编译报错问题
  • g++ -E test.cpp > test.i,发现加载的unwind.h文件路径不是/usr/include/unwind.h
extern "C"{
     6  # 1 "/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include/unwind.h" 1 3 4
     7  # 35 "/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include/unwind.h" 3 4
     8  #pragma GCC visibility push(default)

  • g++ -v查看头文件查找顺序
Target: ia64-hp-hpux11.31
Configured with: ../gcc/configure 
Thread model: posix
gcc version 4.2.3
 /usr/local/libexec/gcc/ia64-hp-hpux11.31/4.2.3/cc1plus -quiet -v test.cpp -quiet -dumpbase test.cpp -auxbase test -version -o /var/tmp//cc1xfLjN.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../../../ia64-hp-hpux11.31/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../../../include/c++/4.2.3
 /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../../../include/c++/4.2.3/ia64-hp-hpux11.31
 /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../../../include/c++/4.2.3/backward
 /usr/local/include
 /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include
 /usr/include
End of search list.
GNU C++ version 4.2.3 (ia64-hp-hpux11.31)
        compiled by GNU C version 4.2.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0e6e59bd3ba97045581fb6f79b29ba73
 /usr/local/bin/as -x -o /var/tmp//ccORhHIA.o /var/tmp//cc1xfLjN.s
 /usr/local/libexec/gcc/ia64-hp-hpux11.31/4.2.3/collect2 -z +Accept TypeMismatch -u main /usr/lib/hpux32/unix98.o -L/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3 -L/usr/ccs/lib -L/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../.. /var/tmp//ccORhHIA.o -lstdc++ -lunwind -lm -lgcc -lc -lgcc
  • 查找头文件,下面两个目录下均有unwind.h文件,导致引用头文件错误
    • /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include
    • /usr/include
  • 解决方案
#include "/usr/include/unwind.h"

你可能感兴趣的:(c++编程,unwind,hpux,backtrace)