5

I'm trying to build gperf(Google's profiler) from source. During build process the following error comes up :

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

So it seems i need libunwind.

1) I got the library from savannah's git repo. 2) Installed it in /opt/unwind. 3) I also added /opt/unwind/lib/pkgconfig to my PKG_CONFIG_PATH. 4) I edited libunwind.pc so that both pkg-config --cflags --libs libunwind comes up with correct values. 5) I added a libunwind.conf in /etc/ld.so.conf.d/ pointing to /opt/unwind/lib.

After all of these i've rerun ./configure in gperf root directory.

The config.log reads following :

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

So it seems It still does not know where libunwind is.

Then i tried to set environment variables with CFLAGS and LDFLAGS like following :

arif@khost:~/src/gperf$ CFLAGS=`pkg-config --cflags libunwind` LDFLAGS=`pkg-config --libs libunwind` ./configure

Now config.log seems more puzzling :

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.

It reports first that there is libunwind.h but later it cant find it.

config.log also has this curious entry :

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

Also its putting up ac_cv_header_libunwind_h=yes

If i do make here it stops with the following error:

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
Aftnix
  • 4,461
  • 6
  • 26
  • 43

3 Answers3

7

You need the libunwind headers too. Install the libunwind-devel package or equivalent.

rwst
  • 2,515
  • 2
  • 30
  • 36
0

Similar to bwzhou's answer, I tried following the answers in this SO question:

How to add include and lib paths to configure/make cycle?

and was able to finally get past the fatal error: libunwind.h: No such file or directory error when compiling gperftools with libunwind-1.2.1 compiled beforehand. More specifically, I set CPPFLAGS and LDFLAGS using the commands:

export CPPFLAGS='-I'$MY_INSTALL_DIR'/include '$CPPFLAGS

export LDFLAGS='-L'$MY_INSTALL_DIR'/lib '$CPPFLAGS

prior to executing ./configure --prefix=$MY_INSTALL_DIR, where $MY_INSTALL_DIR is my personal, non-standard directory in which I have to install software in the HPC cluster I work with due to lacking adequate permissions. After doing this, I was able to successfully execute make; make install. I hope this is helpful.

Brandon McClure
  • 1,329
  • 1
  • 11
  • 32
-2

Try CPPFLAGS instead of CFLAGS when you invoke configure.

bwzhou
  • 1