Gcc

新編譯的 libstdc++ 中沒有版本符號

  • July 2, 2020

我正在使用以下配置編譯 GCC 10.1 版:

../configure --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/home/user/toolchain/gcc  --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --enable-shared --enable-gnu-unique-object --with-linker-hash-style=gnu

編譯完成後,似乎我在編譯的 listdc++.so 中沒有任何版本符號:

> strings ./x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.28 | grep GLIBCXX
 GLIBCXX_FORCE_NEW
 GLIBCXX_DEBUG_MESSAGE_LENGTH

(僅此而已)(順便說一句,如果我在檢查已安裝的庫之前’make install’ gcc,我會得到相同的結果)

轉到另一個系統,同樣的命令問題(輸出被截斷):

> strings /usr/lib64/libstdc++.so.6.0.28 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.5
[ ... ]
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
[ ... ]

為什麼我在新編譯的 gcc/libstdc++ 版本中沒有得到版本符號?

實際發現錯誤,在為系統配置GCC時,我在libstdc++v3的config.log中發現了這個:

configure:74963: WARNING: === Linker version 2501 is too old for
configure:74965: WARNING: === full symbol versioning support in this release of GCC.
configure:74967: WARNING: === You would need to upgrade your binutils to version
configure:74969: WARNING: === 21400 or later and rebuild GCC.
configure:74971: WARNING: === Symbol versioning will be disabled.

編譯一個較新版本的 (binutils) ld 並用它重建 gcc 就可以了。

引用自:https://unix.stackexchange.com/questions/596280