【发布时间】:2013-06-01 01:37:15
【问题描述】:
我正在尝试从源代码构建 gperf(Google 的分析器)。在构建过程中出现以下错误:
src/stacktrace_config.h:58:5: error: #error Cannnot calculate stack trace: need either libunwind or frame-pointers (see INSTALL file)
src/stacktrace.cc:109:3: error: #error Cannot calculate stack trace: will need to write for your environment
make: *** [stacktrace.lo] Error 1
看来我需要libunwind。
1) 我从 savannah 的 git repo 获得了这个库。
2)安装在/opt/unwind。
3) 我还将/opt/unwind/lib/pkgconfig 添加到我的PKG_CONFIG_PATH。
4) 我编辑了libunwind.pc,以便pkg-config --cflags --libs libunwind 都得到正确的值。
5) 我在/etc/ld.so.conf.d/ 中添加了一个libunwind.conf 指向/opt/unwind/lib。
在所有这些之后,我在 gperf 根目录中重新运行 ./configure。
config.log 内容如下:
configure:15852: checking libunwind.h usability
configure:15852: gcc -c -g -O2 conftest.c >&5
conftest.c:67:23: fatal error: libunwind.h: No such file or directory
compilation terminated.
configure:15852: result: no
<***snip****>
configure:15852: checking libunwind.h presence
configure:15852: gcc -E conftest.c
conftest.c:34:23: fatal error: libunwind.h: No such file or directory
compilation terminated.
<***snip***>
ac_cv_header_libunwind_h=no
看来它还是不知道libunwind在哪里。
然后我尝试使用 CFLAGS 和 LDFLAGS 设置环境变量,如下所示:
arif@khost:~/src/gperf$ CFLAGS=`pkg-config --cflags libunwind` LDFLAGS=`pkg-config --libs libunwind` ./configure
现在config.log 似乎更令人费解了:
configure:15852: checking libunwind.h usability
configure:15852: gcc -c -I/opt/unwind/include conftest.c >&5
configure:15852: $? = 0
configure:15852: result: yes
configure:15852: checking libunwind.h presence
configure:15852: gcc -E conftest.c
conftest.c:34:23: fatal error: libunwind.h: No such file or directory
compilation terminated.
它首先报告有libunwind.h,但后来它找不到它。
config.log 也有这个奇怪的条目:
configure:15852: WARNING: libunwind.h: accepted by the compiler, rejected b y the preprocessor!
configure:15852: WARNING: libunwind.h: proceeding with the compiler's result
还有ac_cv_header_libunwind_h=yes
如果我在这里执行make,它会停止并出现以下错误:
In file included from src/stacktrace.cc:65:0:
src/stacktrace_libunwind-inl.h:46:23: fatal error: libunwind.h: No such file or directory
compilation terminated.
make: *** [stacktrace.lo] Error 1
【问题讨论】: