求助:在CentOS 6.9上安装GLIBCXX_3.4.15的方法
Hey, I’ve dealt with this exact problem on CentOS 6.9 before—since the system ships with GCC 4.4.7, which only supports up to GLIBCXX_3.4.13, upgrading the system-wide libstdc++ would break your existing apps. Instead, we can install a standalone version of the library just for your Garry's Mod server. Here are two reliable methods:
Method 1: Compile a Newer GCC to a Custom Directory (Most Stable)
This approach keeps the new library isolated from your system, so no risk to other applications:
Install build dependencies
First, grab the tools needed to compile GCC:yum install -y gcc-c++ make wget bzip2Download and extract GCC 4.9.4 (supports GLIBCXX_3.4.15)
GCC 4.9.x is the minimum version that includes theGLIBCXX_3.4.15symbol we need:cd /usr/local/src wget https://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2 tar -xjvf gcc-4.9.4.tar.bz2 cd gcc-4.9.4Fetch required prerequisites
Use GCC's built-in script to download dependencies like MPFR, GMP, and MPC:./contrib/download_prerequisitesConfigure and compile GCC
We’ll install it to/usr/local/gcc-4.9.4to avoid overwriting system files:mkdir build cd build ../configure --prefix=/usr/local/gcc-4.9.4 --disable-multilib make -j$(nproc) # Uses all CPU cores to speed up compilation (this takes time!) make installPoint Garry's Mod to the new library
Before starting the server, tell it to use our custom libstdc++ first:export LD_LIBRARY_PATH=/usr/local/gcc-4.9.4/lib64:$LD_LIBRARY_PATH ./srcds_run [your server launch arguments]To make this permanent, add the
exportline to your server’s startup script.
Method 2: Copy a Standalone libstdc++.so.6 to Your Server Directory
If compiling feels too heavy, you can copy the required library file directly to your Garry's Mod bin folder:
Get the libstdc++.so.6 file
If you used Method 1, copy it from your custom GCC install:cp /usr/local/gcc-4.9.4/lib64/libstdc++.so.6 /path/to/your/garrysmod/bin/Alternatively, you can copy it from another CentOS 6 system that has the library installed (same architecture).
Launch the server with the local library
Start the server while forcing it to use the library in thebinfolder:LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH ./srcds_run [your server launch arguments]
Verify the Fix
To confirm the new library includes GLIBCXX_3.4.15, run:
strings /usr/local/gcc-4.9.4/lib64/libstdc++.so.6 | grep GLIBCXX_3.4.15
If you see GLIBCXX_3.4.15 in the output, you’re good to go.
内容的提问来源于stack exchange,提问作者Matt

