链接到 TLS libpthread-2.3.4.so 库而不是系统 libpthread 库

发布于 2024-12-23 12:24:24 字数 370 浏览 1 评论 0原文

我正在使用 /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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱她像谁 2024-12-30 12:24:24

据我了解,链接器正在错误的 pthread 库中寻找引用

您的理解是不正确

/usr/lib/libpthread.so 是一个链接器脚本,它将您的程序与 libpthread.so.0libpthread_nonshared 链接起来.alibpthread.so.0 是(应该是)一个符号链接,最有可能是 libpthread-2.3.4.so

您的系统上可能安装了多个版本的 libpthread-2.3.4.so:一个在 /lib/i686 中,一个在 /lib/tls 中code>,也许也是 /lib 中的一个。在运行时使用哪一个取决于您的硬件和内核。

以下命令打印什么?

find /lib -name 'libpthread.so.0' | xargs nm -A | grep pthread_setaffinity_np

ldd /usr/bin/date

as far as I understand, the linker is looking for the reference in the wrong pthread library

Your understanding is incorrect.

The /usr/lib/libpthread.so is a linker script, which links your program with libpthread.so.0 and libpthread_nonshared.a. The libpthread.so.0 is (should be) a symlink, most likely to libpthread-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?

find /lib -name 'libpthread.so.0' | xargs nm -A | grep pthread_setaffinity_np

ldd /usr/bin/date
清浅ˋ旧时光 2024-12-30 12:24:24

它可能不起作用。 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)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文