【发布时间】:2021-06-04 06:35:05
【问题描述】:
据我所知,静态库不能依赖于 Linux 中的共享库。但是,当我编译一个链接到 glog.a 和 gflags.a 的程序时,编译器会报告以下错误:
> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libglog.a(libglog_la-utilities.o):
> In function `google::GetStackTrace(void**, int, int) [clone .part.7]':
> (.text+0xad): undefined reference to `_Ux86_64_getcontext'
> (.text+0xb8): undefined reference to `_ULx86_64_init_local'
> (.text+0xe7): undefined reference to `_ULx86_64_step' (.text+0x100):
> undefined reference to `_ULx86_64_get_reg' (.text+0x120): undefined
> reference to `_ULx86_64_step' collect2: error: ld returned 1 exit
> status
这个编译错误也可以通过链接 unwind.so 来解决。但我觉得奇怪的是,为什么 libglog.a 会依赖共享库?这不是不可能吗?
【问题讨论】:
标签: linux gcc shared-libraries static-libraries