链接到 TLS libpthread-2.3.4.so 库而不是系统 libpthread 库
我正在使用 /usr/include/nptl/pthread.h 中的 pthread_setaffinity_np 等函数。
然而,链接器抱怨找不到“pthread_setaffinity_np”,据我了解,链接器正在错误的pthread库(/usr/lib/libpthread.so)中寻找引用,该库不包括对CPU的支持亲和力。我使用的是 RedHat 4。
我相信我必须链接到包含此函数的 /lib/tls/libpthread-2.3.4.so 。然而,链接到 libpthread-2.3.4.so 会导致其他链接器错误。
在 RedHat 4 上链接到 libpthread-2.3.4.so 的正确方法是什么?
预先感谢,
保罗
I am using functions such as pthread_setaffinity_np from the /usr/include/nptl/pthread.h.
The linker is however complaining that the "pthread_setaffinity_np" is not found, as far as I understand, the linker is looking for the reference in the wrong pthread library (/usr/lib/libpthread.so) which doesn't include support for CPU affinity. I am on RedHat 4.
I believe I have to link to /lib/tls/libpthread-2.3.4.so which includes this function. However linking to libpthread-2.3.4.so caused other linker errors.
What is the proper way of linking to libpthread-2.3.4.so on RedHat 4?
Thanks in advance,
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的理解是不正确。
/usr/lib/libpthread.so
是一个链接器脚本,它将您的程序与libpthread.so.0
和libpthread_nonshared 链接起来.a
。libpthread.so.0
是(应该是)一个符号链接,最有可能是libpthread-2.3.4.so
。您的系统上可能安装了多个版本的
libpthread-2.3.4.so
:一个在/lib/i686
中,一个在/lib/tls
中code>,也许也是/lib
中的一个。在运行时使用哪一个取决于您的硬件和内核。以下命令打印什么?
Your understanding is incorrect.
The
/usr/lib/libpthread.so
is a linker script, which links your program withlibpthread.so.0
andlibpthread_nonshared.a
. Thelibpthread.so.0
is (should be) a symlink, most likely tolibpthread-2.3.4.so
.There are likely several versions of
libpthread-2.3.4.so
installed on your system: one in/lib/i686
, one in/lib/tls
, perhaps also one in/lib
. Which one is used at runtime depends on your hardware and your kernel.What do the following commands print?
它可能不起作用。 NPTL 现在位于 GNU libc 中。它与内核的版本密切相关(并且您可能正在使用一些带有旧内核的古老发行版。)。
好的解决方案是将您的系统升级到提供足够新的 NPTL(以及足够新的内核)来满足您的需求。处理器亲和性在pthread库(通常与
libc
打包)内部和内核内部(因为它与调度程序相关)进行处理。为什么不安装例如CentOS 6(这是RedHat 的衍生品)?
It probably might not work. NPTL is now in the GNU libc. And it is intimately related to the version of the kernel (and you are probably using some ancient distribution with an old kernel.).
The good solution is to upgrade your system to something providing a recent enough NPTL (and recent enough kernel) to suit your needs. Processor affinity is handled both inside the pthread library (often packaged with
libc
) and inside the kernel (because it is related to the scheduler).Why don't you install e.g. CentOS 6 (which is a derivative of RedHat)?