源码安装libunwind库
源码安装libunwind库
下载libunwind源码
https://github.com/libunwind/libunwind/releases/download/v1.7.2/libunwind-1.7.2.tar.gz
注:需要下载github上release版本,如果直接下载master分支上源码,将可能出现各种编译报错
Linux Centos
[root@localhost libunwind-1.7.2]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"[root@localhost libunwind-1.7.2]#
[root@localhost gb]# pwd
/home/gb
[root@localhost gb]# mkdir build
[root@localhost gb]# ls -tlr
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxr-xr-x. 9 gb gb 4096 May 17 17:05 gperftools-2.16
[root@localhost gb]# tar -zxvf libunwind-1.7.2.tar.gz
[root@localhost gb]# cd libunwind-1.7.2/
[root@localhost libunwind-1.7.2]# ./configure --prefix=/home/gb/build
[root@localhost libunwind-1.7.2]# make
[root@localhost libunwind-1.7.2]# make install
[root@localhost libunwind-1.7.2]# cd ../
[root@localhost gb]# ls -tlr
total 8984
drwxrwxr-x. 8 root root 273 Jul 30 2023 libunwind-1.7.2
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxr-xr-x. 10 gb gb 4096 May 17 17:32 gperftools-2.16
drwxrwxr-x. 2 gb gb 6 May 17 17:42 build
[root@localhost gb]#
[root@localhost gb]# cd build/
[root@localhost build]# ls -tlr
total 4
drwxr-xr-x. 3 root root 4096 May 17 17:47 lib
drwxr-xr-x. 2 root root 174 May 17 17:47 include
[root@localhost build]# cd lib
[root@localhost lib]# ls -tlr
total 5736
-rwxr-xr-x. 1 root root 627368 May 17 17:47 libunwind.so.8.0.1
lrwxrwxrwx. 1 root root 18 May 17 17:47 libunwind.so.8 -> libunwind.so.8.0.1
lrwxrwxrwx. 1 root root 18 May 17 17:47 libunwind.so -> libunwind.so.8.0.1
-rwxr-xr-x. 1 root root 967 May 17 17:47 libunwind.la
-rwxr-xr-x. 1 root root 862264 May 17 17:47 libunwind-x86_64.so.8.0.1
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-x86_64.so.8 -> libunwind-x86_64.so.8.0.1
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-x86_64.so -> libunwind-x86_64.so.8.0.1
-rwxr-xr-x. 1 root root 1048 May 17 17:47 libunwind-x86_64.la
-rwxr-xr-x. 1 root root 198296 May 17 17:47 libunwind-coredump.so.0.0.0
lrwxrwxrwx. 1 root root 27 May 17 17:47 libunwind-coredump.so.0 -> libunwind-coredump.so.0.0.0
lrwxrwxrwx. 1 root root 27 May 17 17:47 libunwind-coredump.so -> libunwind-coredump.so.0.0.0
-rwxr-xr-x. 1 root root 1101 May 17 17:47 libunwind-coredump.la
-rwxr-xr-x. 1 root root 127704 May 17 17:47 libunwind-ptrace.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-ptrace.so.0 -> libunwind-ptrace.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-ptrace.so -> libunwind-ptrace.so.0.0.0
-rwxr-xr-x. 1 root root 1087 May 17 17:47 libunwind-ptrace.la
-rwxr-xr-x. 1 root root 42824 May 17 17:47 libunwind-setjmp.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-setjmp.so.0 -> libunwind-setjmp.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-setjmp.so -> libunwind-setjmp.so.0.0.0
-rwxr-xr-x. 1 root root 1087 May 17 17:47 libunwind-setjmp.la
-rw-r--r--. 1 root root 1416038 May 17 17:47 libunwind.a
-rw-r--r--. 1 root root 1736082 May 17 17:47 libunwind-x86_64.a
-rw-r--r--. 1 root root 462772 May 17 17:47 libunwind-coredump.a
-rw-r--r--. 1 root root 291124 May 17 17:47 libunwind-ptrace.a
-rw-r--r--. 1 root root 69560 May 17 17:47 libunwind-setjmp.a
lrwxrwxrwx. 1 root root 18 May 17 17:47 libunwind-generic.a -> libunwind-x86_64.a
lrwxrwxrwx. 1 root root 19 May 17 17:47 libunwind-generic.so -> libunwind-x86_64.so
drwxr-xr-x. 2 root root 137 May 17 17:47 pkgconfig
[root@localhost lib]#
ARM64 交叉编译
[root@localhost libunwind-1.7.2]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"[root@localhost libunwind-1.7.2]#
[root@localhost gb]# pwd
/home/gb
[root@localhost gb]# mkdir build
[root@localhost gb]# ls -tlr
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxr-xr-x. 9 gb gb 4096 May 17 17:05 gperftools-2.16
[root@localhost gb]# tar -zxvf libunwind-1.7.2.tar.gz
[root@localhost gb]# cd libunwind-1.7.2/
#设置交叉工具链安装的目录
[root@localhost gb]# export PATH=$PATH:/opt/chain_tool/gcc_arm_10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin
[root@localhost libunwind-1.7.2]# ./configure --host=aarch64-none-linux-gnu --prefix=/home/gb/build
[root@localhost gperftools-2.16]# make
[root@localhost gperftools-2.16]# make install
[root@localhost gperftools-2.16]# cd ../
[root@localhost gb]# ls -tlr
total 8984
drwxrwxr-x. 8 root root 273 Jul 30 2023 libunwind-1.7.2
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxr-xr-x. 10 gb gb 4096 May 17 17:32 gperftools-2.16
drwxrwxr-x. 2 gb gb 6 May 17 17:42 build
[root@localhost gb]#
[root@localhost gb]# cd build/
[root@localhost build]# ls -tlr
total 4
drwxr-xr-x. 3 root root 4096 May 17 17:47 lib
drwxr-xr-x. 2 root root 174 May 17 17:47 include
[root@localhost build]# cd lib
[root@localhost lib]# ls -tlr
total 5736
-rwxr-xr-x. 1 root root 627368 May 17 17:47 libunwind.so.8.0.1
lrwxrwxrwx. 1 root root 18 May 17 17:47 libunwind.so.8 -> libunwind.so.8.0.1
lrwxrwxrwx. 1 root root 18 May 17 17:47 libunwind.so -> libunwind.so.8.0.1
-rwxr-xr-x. 1 root root 967 May 17 17:47 libunwind.la
-rwxr-xr-x. 1 root root 862264 May 17 17:47 libunwind-x86_64.so.8.0.1
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-x86_64.so.8 -> libunwind-x86_64.so.8.0.1
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-x86_64.so -> libunwind-x86_64.so.8.0.1
-rwxr-xr-x. 1 root root 1048 May 17 17:47 libunwind-x86_64.la
-rwxr-xr-x. 1 root root 198296 May 17 17:47 libunwind-coredump.so.0.0.0
lrwxrwxrwx. 1 root root 27 May 17 17:47 libunwind-coredump.so.0 -> libunwind-coredump.so.0.0.0
lrwxrwxrwx. 1 root root 27 May 17 17:47 libunwind-coredump.so -> libunwind-coredump.so.0.0.0
-rwxr-xr-x. 1 root root 1101 May 17 17:47 libunwind-coredump.la
-rwxr-xr-x. 1 root root 127704 May 17 17:47 libunwind-ptrace.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-ptrace.so.0 -> libunwind-ptrace.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-ptrace.so -> libunwind-ptrace.so.0.0.0
-rwxr-xr-x. 1 root root 1087 May 17 17:47 libunwind-ptrace.la
-rwxr-xr-x. 1 root root 42824 May 17 17:47 libunwind-setjmp.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-setjmp.so.0 -> libunwind-setjmp.so.0.0.0
lrwxrwxrwx. 1 root root 25 May 17 17:47 libunwind-setjmp.so -> libunwind-setjmp.so.0.0.0
-rwxr-xr-x. 1 root root 1087 May 17 17:47 libunwind-setjmp.la
-rw-r--r--. 1 root root 1416038 May 17 17:47 libunwind.a
-rw-r--r--. 1 root root 1736082 May 17 17:47 libunwind-x86_64.a
-rw-r--r--. 1 root root 462772 May 17 17:47 libunwind-coredump.a
-rw-r--r--. 1 root root 291124 May 17 17:47 libunwind-ptrace.a
-rw-r--r--. 1 root root 69560 May 17 17:47 libunwind-setjmp.a
lrwxrwxrwx. 1 root root 18 May 17 17:47 libunwind-generic.a -> libunwind-x86_64.a
lrwxrwxrwx. 1 root root 19 May 17 17:47 libunwind-generic.so -> libunwind-x86_64.so
drwxr-xr-x. 2 root root 137 May 17 17:47 pkgconfig
[root@localhost lib]#
注:交叉编译libunwind-0.99.tar.gz时,出现下面报错误提示
configure: WARNING: If you wanted to set the --build type, don't use --host.If a cross compiler is detected then cross compile mode will be used.
checking for egrep... grep -E
Configuring NCURSES 5.7 ABI 5 (Tue Apr 22 11:06:28 CST 2025)
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `aarch64-none-linux-gnu': machine `aarch64' not recognized
configure: error: /bin/sh ../config.sub aarch64-linux-gnu failed
解决方法:下载更高版本源码,因低版本confgiure不识别aarch64-none-linux-gnu
参考文献
libunwind github下载地址
Invalid configuration ‘aarch64-linux-gnu‘: machine ‘aarch64‘ not recognized