Win10 linux subsystem libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast

Solution 1:

Add LIBGL_ALWAYS_INDIRECT variable to /etc/bash.bashrc solved my error.

export LIBGL_ALWAYS_INDIRECT=1

Don't know what's the actual usage. But maybe useful, because XLauch confg says it requires this.

My error occurs when invoke emacs from wsl2, and display in XLauch (vcxsrv):

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

I find the solution according to:

  • The Ultimate Emacs Hacking Tutorial in Windows 10 WSL 2
  • Does WSL support openGL?

Solution 2:

Again, apologies for answering my own question, but this seems to be the only way to put up an answer to the problem, as I detailed in my question.

On my Win10 Linux Ubuntu subsystem, the mesa drivers were in this directory: /usr/lib/x86_64-linux-gnu/; unlike the answer linked to above, there was no Mesa (or mesa, or...) subdirectory. So I created a tmp dir somewhere else, and moved the mesa drivers (two, plus two links) to that tmp dir. And now my GTK-based app works.

The two drivers were /usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0.0.0 and /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0; the two links were /usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0 and /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0. The cmd to move the files was sudo mv /usr/lib/x86_64-linux-gnu/*mesa* tmp/ (make sure the tmp/ dir is not in a place where library files live).

I make no claims about whether the mesa drivers are needed for something else, which is why I moved them to a tmp/ dir rather than deleting them. But after moving them, my GTK app worked.

Solution 3:

On WSL2 with Ubuntu 20.04:

  1. don't set LIBGL_ALWAYS_INDIRECT (remove the export from your .bashrc or .profile)

  2. Set Wgl="False" in your XLaunch configuration

See this comment on GitHub.

Solution 4:

If you configure Xlaunch it via UI, in the additional parameters add -nowgl

-[no]wgl
    Enable the GLX extension to use the native Windows WGL interface for hardware-accelerated OpenGL