Force GCC to static-link e.g. pthreads (and not dynamic link)

前端 未结 1 1997
我寻月下人不归
我寻月下人不归 2021-02-09 09:53

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

相关标签:
1条回答
  • 2021-02-09 10:20

    While linking 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.

    So linking libpthread.a into your shared library will:

    1. Cause your program to crash when moved to a machine with a different version of glibc
    2. Cause your existing program to crash when your current machine's glibc is upgraded, but your module is not re-linked against updated libpthread.a.

    Spare yourself aggravation, and don't do that.

    0 讨论(0)
提交回复
热议问题