简体   繁体   English

如果 pthread API 在 libc 中,是否需要 libpthread

[英]Is libpthread needed if the pthread API is in libc

Looking at the output of readelf -s /lib/x86_64-linux-gnu/libc.so.6 on my Ubuntu 22.04 box, I see (what looks to be) the entire pthread API contained in the .text section.查看我的 Ubuntu 22.04 框中的readelf -s /lib/x86_64-linux-gnu/libc.so.6的 output,我看到(看起来是) .text部分中包含的整个 pthread API。

As a sanity check, I successfully compiled and ran作为完整性检查,我成功编译并运行了

#include <stdio.h>
#include <string.h>

#include <pthread.h>

static void *
func(void *args) {
    return args;
}

int main() {
    int ret;
    pthread_t thread;

    ret = pthread_create(&thread, NULL, func, NULL);
    if ( ret != 0 ) {
        fprintf(stderr, "pthread_create: %s\n", strerror(ret));
        return ret;
    }
    pthread_join(thread, NULL);

    return 0;
}

without using -pthread .不使用-pthread

Given all of this, is there any purpose to libpthread on my computer other than providing support for older applications which expect it to be there?鉴于所有这些,除了为期望它存在的旧应用程序提供支持之外,我的计算机上的 libpthread 是否还有其他用途?

Is libpthread needed if the pthread API is in libc如果 pthread API 在 libc 中,是否需要 libpthread

No.不。

is there any purpose to libpthread on my computer other than providing support for older applications which expect it to be there?除了为希望它存在的旧应用程序提供支持之外,我的计算机上的 libpthread 是否还有其他用途?

No.不。

See https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread .请参阅https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread Since then libpthread is an empty library.从那时起,libpthread 就是一个空库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM