30

I have problems when compile SFML-project(don't see any graphic):

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

This error can be solved by simple reinstalling nvidia-drivers through this tutorial: https://askubuntu.com/a/451248/341889

..but when i get new updates - this error is returning ;( What should I do? It's not the solution - not use system's update...

P.S. and yes, i saved all changes after installing nvidia-drivers

  • 1
    This happens to me if I try to launch an OpenGL executable dynamically loading the mesa libGL.so: LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa ./glprogram. By default, my Ubuntu 16.04 uses /usr/lib/nvidia-361/libGL.so because of /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf and it all works fine. – Ciro Santilli 新疆改造中心 六四事件 法轮功 Sep 4 '16 at 16:29
24

The swrast thing is the software renderer. That means it's not finding the hardware driver for your graphics card. There are a bunch of libGL libraries installed and a bunch of of symbolic links to those libraries. To see these run this from the shell:

find /usr -iname "*libGL.so*" -exec ls -l -- {} + 

Now the probable cause of your problem is that installing graphics drivers sometimes break these symbolic links. (Specifically /usr/local/lib/libGL.so.1.2.0 is likely to be either the wrong lib or a sym link to the wrong link).

To work out what library the OpenGL programs are trying to run you can turn on a bit of verbosity and run a simple OpenGL program. You can verify this using the standard OpenGL test program:

LIBGL_DEBUG=verbose glxgears

Hopefully that will fail in the same way as SFML. With LIBGL_DEBUG it should tell you what OpenGL library it's trying to load. Furthermore the lib it will be trying to load will almost certainly be /usr/local/lib/libGL.so.1.2.0 (Edit: This was the standard OpenGL library on my machine at the time I answered this. It may well be some other version on your machine now).

So the solution (in this case) is to make sure that /usr/local/lib/libGL.so.1.2.0 is a symbolic link pointing at the right OpenGL library. In my case I have the Nvidia 3.40 driver so I ran:

ln -s /usr/lib/nvidia-340/libGL.so.1 /usr/local/lib/libGL.so.1.2.0

But you'll want to point it at the OpenGL lib that is appropriate for you (listed in the first find command).

In summary: installing (proprietary) graphics drivers can break the symbolic links used for OpenGL libs. To solve this problem manually fix the symbolic links (fix /usr/local/lib/libGL.so.1.2.0 first).

  • This issue helped me understand the error message, but not fixing it. The "re-install nvidia drivers" answer helped was a good complement as it actually fixed the problem for me. – henko Sep 29 '15 at 7:00
  • @henko yes reinstalling nvidia drivers is probably the fastest and easiest way to sort this out. Fall back to this approach if for whatever reason reinstalling the drivers doesn't fix your problem and you need to get your hands dirty. – demented hedgehog Sep 30 '15 at 0:57
  • 3
    I understood every part, except "almost certainly be /usr/local/lib/libGL.so.1.2.0". Mine shows "libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so" and all these file exist in my system... – Samuel Li Oct 19 '15 at 23:21
  • I'm just saying that that was the problem on my machine (with an up-to-date ubuntu derived os). So at that time that was likely to be the current opengl lib version. These days it may well have some other version though mine is still pointing at 1.2.0 on a new machine. – demented hedgehog Jan 1 '16 at 9:43
  • 1
    Thanks again for your explanation; I do understand better about the problem. I also want to point out that in my case, there's a confirmed bug in the ubuntu swrast.so, and people have been discussing it. – Samuel Li Feb 19 '16 at 0:31
4

I was having problems getting the correct symlink to point at the nVidia driver and I found another way that works for me.

It is outlined here.

And it lists on how to install the nVidia driver via PPA which is avaliable for 349.16, the latest version.

First uninstall any nVidia drivers currently installed by opening a terminal window (Ctrl + ALT + T) and typing

sudo apt-get remove nvidia*

Reboot your system

Then open another terminal and type the following

sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get install nvidia-349 nvidia-settings
sudo add-apt-repository -r ppa:xorg-edgers/ppa

Then reboot again

I tried it after getting lost with the symlinks and steam worked fine immediately after the installing the driver and again it was still working after I had 400+ megs of system updates.

  • 2
    I would not suggest to leave xorg-edgers ppa after the driver is installed. A lot of unstable packages will come in updates. – Pilot6 May 21 '15 at 13:54
  • just removing the nvidia* already solved this problem for me! – xtofl Jun 9 '17 at 16:33
4

I had the same issue on Ubuntu 16.10 with the nvidia-340 drivers and none of the solutions here worked for me.

Turns out the 32-bit libraries were not on the library path.

This one liner worked for me:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib32/nvidia-340"
2

To provide an alternative to Adrian's answer: if you prefer to use proprietary drivers sourced directly from NVIDIA instead of those found in a PPA, installing (or in my case, re-installing) the latest proprietary driver can help eliminate the swrast error.

If you don't have the NVIDIA driver yet, download the driver from NVIDIA's website. Next, switch to tty (ctrl+alt+F1) and turn off your login manager:

If using lightdm, $ sudo service lightdm stop

If using gdm, $ sudo service gdm stop

Navigate to the install script and run it, and follow the prompts. Don't worry if the pre-install script fails. I always accept registering DKMS and the 32-bit compatibility libraries. After the driver is installed, restart your machine:

$ sudo reboot

If you already have an install script from an older NVIDIA driver, simply run the NVIDIA driver install script as oulined above, but with the "--update" option:

$ sudo ./NVIDIA-Linux-x86_64-***.**.run --update

This will get you the most up-to-date version of the driver.

Doing this fixed my libGL error: failed to load driver: swrast error.

2

I have to admit, I'm not sure why this works for me, but it did. In this particularly case "fixing" the ld.so.conf.d entries by adding a new entry like this works:

sudo ln -s /usr/lib/nvidia-381/ld.so.conf /etc/ld.so.conf.d/nvidia64.conf
sudo ldconfig 

This makes sense, until you run the following find:

$ find -L /etc/ld.so.conf.d -type f | xargs grep -i nvidia
/etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf:/usr/lib/nvidia-381
/etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf:/usr/lib32/nvidia-381
/etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf:/usr/lib/nvidia-381
/etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf:/usr/lib32/nvidia-381
/etc/ld.so.conf.d/nvidia64.conf:/usr/lib/nvidia-381
/etc/ld.so.conf.d/nvidia64.conf:/usr/lib32/nvidia-381

Why having the same entries in triplicate works, but not in duplicate, I have no idea!

  • Works for me on Ubunu 17.04. Just a note - the path is /usr/lib/nvidia-xxx where xxx is the driver number so adapt the command to that. – user2082382 Oct 8 '17 at 18:06
2

Here's an apt-only solution that worked for me, no symlinking or mucking around with ld.so.conf.d:

apt install --reinstall libgl1-mesa-glx:i386
apt install mesa-utils nvidia-driver nvidia-driver-libs-i386
-3

I was facing this weird issue when I ssh to my Ubuntu VM from my Macbook Pro, but installing the below Nvidia driver on my Ubuntu 16.04 fixed the issue. Hope this works for you.

sudo apt-get install nvidia-331

  • Why would you install Nvidia GPU drivers on a VM guest system? Ó_ò – David Foerster Oct 28 '16 at 9:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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