Create or Activate a Conda Environment If you don’t already have a Conda environment, create one:
conda create -n gcc_env python=3.8
conda activate gcc_env
Install libstdcxx-ng and gcc via Conda
Conda provides libstdcxx-ng, which includes the necessary libstdc++.so.6 with newer ABI versions. To install the required dependencies:
conda install -c conda-forge libstdcxx-ng
conda install -c conda-forge gcc
Verify the ABI Version After installing, verify that the required ABI version (CXXABI_1.3.9) is available:
strings $(conda info --base)/envs/gcc_env/lib/libstdc++.so.6 | grep CXXABI
This should list the ABI versions available, including CXXABI_1.3.9.
Run Your Python Packages in the Conda Environment Now, you can install and use the Python packages like matplotlib and pillow in this environment:
conda install matplotlib pillow
Since the environment is using the Conda-provided libstdc++.so.6, your Python packages should now work without throwing the ABI version error.
Ensure Conda Environment is Active Whenever you want to run programs that require the updated libstdc++, make sure you activate the Conda environment:
conda activate gcc_env
Summary
Conda offers an easy way to manage and upgrade libraries like libstdc++ and gcc in your environment without affecting the system-wide installation. By installing libstdcxx-ng and gcc from Conda, you get the required ABI version, and your Python packages will be able to run without issues.
This method provides a hassle-free solution since Conda automatically manages dependencies and paths.
To resolve the issue with the outdated libstdc++.so.6
not providing the required ABI version (CXXABI_1.3.9), you need to update the libstdc++
library in your local environment, as you likely don't have sudo
privileges to update system-wide libraries. Here's the step-by-step solution:
-
Download GCC (which provides
libstdc++
)libstdc++.so.6
is part of the GCC toolchain. You can install a newer version of GCC locally and point your environment to the newlibstdc++.so.6
file.
# Navigate to your software directory mkdir -p /data/pnlx/home/rez3/software cd /data/pnlx/home/rez3/software # Download the latest GCC source code (or choose a version compatible with your requirements) wget https://ftp.gnu.org/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.gz tar -xvzf gcc-10.3.0.tar.gz cd gcc-10.3.0 # Download prerequisites for GCC ./contrib/download_prerequisites # Create a directory for GCC build mkdir build cd build # Configure GCC with a prefix pointing to your local directory ../configure --prefix=$HOME/local --disable-multilib --enable-languages=c,c++ # Build and install GCC make -j$(nproc) make install
-
Update the
LD_LIBRARY_PATH
to Include the Newlibstdc++
After installing GCC, you need to update your environment to use the newly installed
libstdc++.so.6
.# Set environment variables to point to the new libstdc++.so.6 export LD_LIBRARY_PATH=$HOME/local/lib64:$LD_LIBRARY_PATH
-
Verify the ABI Version Once the new
libstdc++.so.6
is installed, you can check its ABI version:strings $HOME/local/lib64/libstdc++.so.6 | grep CXXABI
This should show the supported ABI versions, including
CXXABI_1.3.9
. -
Test Your Python Packages (matplotlib, pillow) Now, retry importing
matplotlib
,pillow
, or any other package that was failing due to the missing ABI version. Since the newlibstdc++.so.6
should be in yourLD_LIBRARY_PATH
, the Python packages should now work correctly.
This process installs a newer version of libstdc++.so.6
without needing to update the system-wide libraries, allowing you to meet the ABI requirements for your Python packages.