1

我有一个静态链接的应用程序(sample.a),我想使用启用 PIC 的第三方库(third-party-lib.a)构建它。请注意,第三方库不是共享库。它是一个启用 PIC 的静态库。

谁能建议我该怎么做?

我尝试将我的库与第三方库链接,就像我们通常链接静态库一样,但它给了我一个错误:

/usr/lib/libc_nonshared.a(stack_chk_fail_local.oS): 在函数__stack_chk_fail_local': (.text+0x10): undefined reference to__stack_chk_fail'

提前致谢。

4

1 回答 1

0

I'd suggest using nm to try finding the symbols involved. Good idea would be also to check if there isn't any #define you need to take care of or similar. By itself, a PIC-enabled static library shouldn't change anything in linking, as long as you compile the rest of the program with -fPIC as well.

Altogether, it doesn't seem to me like something caused by PIC settings. Did you per chance built the code previously with dynamic libraries, and only now switched to static? That could explain missing some bits of configuration involved, among other things.

于 2012-06-07T07:23:31.170 回答