0

There are two approaches that I have tried to install visual studio code on my CentOS 7 system. Both have failed.

Approach 1 - Following official instructions (install via package manager)

The official instructions for installation visual studio code on CentOS is provided here. These instructions recommend installing via package manager rather downloading the RPM for the latest stable release.

In case the link for the instructions breaks in the future, I quote them here:

We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

Then update the package cache and install the package using dnf (Fedora 22 and above):

dnf check-update

sudo dnf install code

Or on older versions using yum:

yum check-update

sudo yum install code

I have followed these steps, and each command succeeds. However, when I run visual studio code with code in my terminal, the visual studio code window is unresponsive.

Approach 2 - Install from standalone RPM downloaded from code.visualstudio.com

My second approach is to go to the code.visualstudio.com downloads page and download the standalone RPM for 64-bit Linux.

The website does not provide a checksum to verify the download, but I checked the file is a valid RPM:

$ file code-1.59.0-1628120127.el8.x86_64.rpm 
code-1.59.0-1628120127.el8.x86_64.rpm: RPM v3.0 bin i386/x86_64 code-1.59.0-1628120127.el8

Next, I attempt to install with yum, which succeeds with an exit code of 0:

$ sudo yum install -y ./code-1.59.0-1628120127.el8.x86_64.rpm 
<snipped>
Installed:
  code.x86_64 0:1.59.0-1628120127.el8                                                         

Complete!
$ echo $?
0

Results

With both approach 1 and approach 2, when I run visual studio code after installation (I run code from my terminal to launch the program), the visual studio code window is unresponsive.

What seems to be the problem

The system requirements page says glibcxx must be version 3.4.21 or later, and glibc must be version 2.15 or later.

My glibc is version 2.17, so the glibc requirement is met:

$ rpm -q glibc
glibc-2.17-324.el7_9.x86_64

When I check my /usr/lib64/libstdc++.so.6 I see that the highest gllibcxx available on my system is 3.4.19:

$ strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH

Assuming my old glibcxx version is the problem, how can I install glibcxx 3.4.21 or later on CentOS 7?

4
  • 1
    I suspect the reason it’s not working is due to the fact the minimum version supported is CentOS 8 and your running CentOS 7. Verify that GLIBCXX is 3.4.21 or later and GLIBC is 2.15 or later
    – Ramhound
    Aug 16, 2021 at 16:53
  • @Ramhound rpm -q glibc shows my glibc is version 2.17. I tried rpm -q glibcxx to check my glibcxx version, but it said package glibcxx is not installed. How can I check my glibcxx version? Aug 16, 2021 at 17:37
  • When I run sudo find /usr/lib* -name 'libstdc++.so.*' I see /usr/lib64/libstdc++.so.6 and /usr/lib64/libstdc++.so.6.0.19. Aug 16, 2021 at 17:40
  • According to the Visual Studio Code website, you need both, which is more than likely the reason, the application is behaving strangely. You might be able to install it as outline here, but I suggest upgrading to CentOS 8 instead, less of a headache for your future self. Relevant information should be contained in the question body instead of a temporary comment.
    – Ramhound
    Aug 16, 2021 at 17:41

1 Answer 1

1

I managed to get visual studio code to work by building libstdc++.so.6 from scratch.

Note that my CentOS 7 system's architecture was x86_64.

I roughly followed the steps at https://gcc.gnu.org/wiki/InstallingGCC. Here are the commands I ran to build libstdc++.so.6 from gcc 7.1.0 source:

sudo yum install gcc gcc-c++   # Installs gcc and g++ 4.8.5
wget http://mirrors.concertpass.com/gcc/releases/gcc-7.1.0/gcc-7.1.0.tar.gz
tar xzf gcc-7.1.0.tar.gz
cd gcc-7.1.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-7.1.0/configure --prefix=$HOME/gcc-7.1.0 --enable-languages=c,c++ --disable-multilib
make                           # I could not use -j, see details below
make install

I then verified that the libstdc++.so.6 I had built had the GLIBCXX I needed:

$ strings $HOME/gcc-7.1.0/lib64/libstdc++.so.6 | grep ^GLIBCXX_3.4... | sort
GLIBCXX_3.4.10
<snip>
GLIBCXX_3.4.21
<snip>
GLIBCXX_3.4.23

I then added the following bash function to my ~/.bashrc:

code() (
    LD_LIBRARY_PATH="$HOME/gcc-7.1.0/lib64" /usr/bin/code "$@"
)

This code bash function provides a convenient way to run visual studio code with the LD_LIBRARY_PATH set so that my libstdc++.so.6 will be found at runtime.

I had already added the yum repo for visual studio code, so I did not run those commands again, but for others those instructions are available here.

Next I installed visual studio code, sourced my ~/.bashrc, and ran visual studio code from the command line:

sudo yum install code    # Install visual studio code through yum
. ~/.bashrc              # Source my ~/.bashrc
code                     # Invoke my code bash function

This time visual studio code started and I was able to interact with the window.


Why did you use gcc and g++ 4.8.5 instead of devtoolset-*?

I tried using devtoolset-8 before to compile gcc from source and that didn't work. Maybe there is a way to get it to work, but I do know that compiling using gcc 4.8.5 installed through yum does work.

Why not provide -j flag to make to speed up compilation?

When I tried providing -j to make to speed up compilation, compilation would fail to find a header (I forget which one).

Why provide --disable-multilib to configure?

If I didn't provide that flag to configure, I would get this error message:

collect2: error: ld returned 1 exit status
configure: error: I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

Since my CentOS 7 had an x86_64 architecture, I opted to use --disable-multilib and build 64-bit-only build artifacts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.