强制GCC静态链接例如pthreads(而不是动态链接) [英] Force GCC to static-link e.g. pthreads (and not dynamic link)
问题描述
当链接 将 让自己加重,不要那样做。 My program is built as a loader and many modules which are shared libraries. Now one of those libraries uses pthreads and it seems its bound to the module dynamically (loaded on startup). Now it'd be simplier if i could force pthreads to be linked into the module file. GCC on linux, how do i do? I guess a libpthread.a is necessary.... While linking So linking Spare yourself aggravation, and don't do that. 这篇关于强制GCC静态链接例如pthreads(而不是动态链接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! libpthread.a
在理论上是可行的,但这是一个非常糟糕的主意。原因是
must 必须完全匹配,否则您会看到奇怪且无法解释的崩溃。 libpthread
是 glibc
和所有所有部分的一部分$ c> glibc
libpthread.a
链接到共享库中:
glibc
glibc
已升级,但您的模块未与更新的 libpthread.a
重新链接。
libpthread.a
into a shared library is theoretically possible, it is a really bad idea. The reason is that libpthread
is part of glibc
, and all parts of glibc
must match exactly, or you'll see strange and un-explainable crashes.libpthread.a
into your shared library will:
glibc
glibc
is upgraded, but your module is not re-linked against updated libpthread.a
.