How to properly build & link the libunwind library

677 Views Asked by At

I need to build the libary libunwind(https://github.com/libunwind/libunwind) on my ubuntu x86_64 pc for my pc and compile and link everything with g++. I am able to build some files, including the static library file libunwind.a but I just cannot link everything together. The already answered Question (What is an undefined reference/unresolved external symbol error and how do I fix it?) has no solution applicable to my problem.

Here is what I've tried so far:

1. clone libunwind and go into the directory "libunwind"
2. autoreconf -i
3. ./configure --prefix=$(pwd)/build
4. make
5. make install

Now i have dozen of files in my build folder

6. I copy the following files from the build folder to my source folder  "libunwindExample", where my main.cpp is located: libunwind-dynamic.h libunwind-x86_64.a, libunwind-x86_64.h, libunwind.h, libunwind-common.h
7. Now I try to compile and link everything together using the command g++ -O0 main.cpp -L/home/.../libunwindExample -lunwind

When execute this command, I'll get a bunch of linker errors, which are telling me that I have a lot of undefined references(see below). I am pretty sure, that this i due to step 6 but I just dont know what i should do instead with all of these built files in the build folder. Just for fun, I tried the procedure for the ARM architecture but it just lead to different undefined references. I really tried erverything, and also searched through the libunwind mail archieve. It would be teriffic i anyone could tell me how to avoid those linker errors.

Linker Errors:

/usr/bin/ld: /home/.../libunwind/src/elfxx.c:253: undefined reference to `lzma_stream_footer_decode'

/usr/bin/ld: /home/.../libunwind/src/elfxx.c:260: undefined reference to `lzma_index_buffer_decode'

/usr/bin/ld: /home/.../libunwind/src/elfxx.c:264: undefined reference to `lzma_index_size'

/usr/bin/ld: /home/.../libunwind/src/elfxx.c:269: undefined reference to `lzma_index_end'

/usr/bin/ld: /home/.../libunwind/src/elfxx.c:266: undefined reference to `lzma_index_uncompressed_size'

/usr/bin/ld: /home/.../libunwind/src/elfxx.c:269: undefined reference to `lzma_index_end'

main.cpp:(just the first code sample from https://eli.thegreenplace.net/2015/programmatic-access-to-the-call-stack-in-c/) (yes,UNW_LOCAL_ONLY is defined before including)

1

There are 1 best solutions below

0
On

You may have run into an upstream bug in libunwind in which the libraries are underlinked.

Try configuring without linking to the compression libraries.

./configure --disable-minidebuginfo --disable-zlibdebuginfo

then follow your other steps.