Failed to load libGL.so on Android

Android

Android Problem Overview


I am using Ubuntu 12.04 (Precise Pangolin) with the Oracle JDK 7, and when I am running the Android emulator from Eclipse, it's giving this error:

[2012-07-04 02:52:10 - Emulator] error libGL.so: cannot open shared object file: No such file or directory 
[2012-07-04 02:52:10 - Emulator] Failed to load libGL.so

Also the emulator is very slow. How can I solve this problem?

Android Solutions


Solution 1 - Android

I have the Android SDK installed into ~/android-sdk-linux_x86, so I did:

ln -s /usr/lib/libGL.so.1 ~/android-sdk-linux_x86/tools/lib/libGL.so

This solves errors just like linking to /usr/lib does, but it doesn't require root and doesn't mess with core system directories.

Solution 2 - Android

On 64-bit Ubuntu 12.04, do it like this:

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Source: Installing required packages (Ubuntu 12.04)

Solution 3 - Android

I am using Ubuntu 12.04 64-bit. Using the following command to solve the problem

 sudo ln -s /usr/lib32/fglrx/libGL.so.1.2 /usr/lib/libGL.so

Note: This is applicable only to those who use the AMD/ATI graphic drivers.

Solution 4 - Android

For 32-bit Ubuntu 12.04 LTS, this worked:

sudo apt-get install libgl1-mesa-dev

None of the following worked:

cd /usr/lib/i386-linux-gnu/mesa/
sudo ln -s libGL.so.1.2 libGL.so 
sudo ln -s libGL.so.1.2 /usr/lib/libGL.so
ln -s libGL.so.1.2 ~/android/android-sdk-linux/tools/lib/libGL.so

Solution 5 - Android

What works for me (ubuntu 12.04 64bit) was just to run :

    sudo apt-get install libgl1-mesa-dev

I found that libGL.so exists in directory /usr/lib/x86_64-linux-gnu/

Installation of 32 bit version was not working.

Solution 6 - Android

On 64 bit Ubuntu 12.04, there is no /usr/lib64. It is /usr/lib only. Also, on my machine, libGL.so isn't present. Instead the file is libGLEW.so

To install /usr/lib/LibGL.so you can run: sudo apt-get install libgl1-mesa-dev

However, it didn't solve the problem for me. In fact, it probably screwed up my system.

Solution 7 - Android

I think I got it right, no warnings and no slowness... This might not work with proprietary drivers, though.

Make sure libgl1-mesa-glx:i386 is installed (even if you got a x64 SO file). Then do:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so

Solution 8 - Android

This worked for me on 64 bit Ubuntu 12.10 and the ADT bundle:

ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 ~/adt-bundle-linux-x86_64/sdk/tools/lib/libGL.so

If you don't have /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 just install libgl1-mesa-glx

sudo apt-get install libgl1-mesa-glx

Solution 9 - Android

Referring to http://developer.android.com/sdk/installing/index.html, I installed ia32-libs and did:

ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/i386-linux-gnu/mesa/libGL.so

That's all I did to solve this problem.

Solution 10 - Android

NVidia Optimus:

Running on dual graphics (intel and nvidia), I used the following:

  1. Install Bumblebee (see: https://wiki.ubuntu.com/Bumblebee#Installation)
  2. Install the required lib.
  3. Run the emulator on the nvidia discrete card.

This should do the trick:

sudo add-apt-repository ppa:bumblebee/stable
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update 
sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic 
sudo apt-get install ia32-libs

Whenever you wish to run the emulator, just use optirun:

optirun emulator @<avd_name>

I should give a warning that I only installed Linux yesterday. So I don't really know what I'm doing….

Solution 11 - Android

I use Linux Mint 14 - 64 bit and for me, it worked :) :

sudo apt-get install libgl1-mesa-glx libgl1-mesa-dev

Solution 12 - Android

On Ubuntu 12.04 64-bit, GNOME 3.4, I first referred to http://developer.android.com/sdk/installing/index.html and installed ia32-lib, which will generate /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0

Then I run the below command and solved this problem:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0 /usr/lib/libGL.so

This is slightly different from gridstation's answer.

I guess there's no need to install the Mesa driver locally, which may cause issues with your real video drivers.

Solution 13 - Android

To make it work on a Ubuntu 12.10 (Quantal Quetzal) 64-bit, you have to do two things:

  1. You have to initialize LD_LIBRARY_PATH

    Example:

    export LD_LIBRARY_PATH=~/tests/android/adt-bundle-linux-x86_64/sdk/tools/lib

Comments: change the path to your location

  1. You have to create a symbolic link

a) Use locate libGL to find the correct library:

rudy@vsolutions:~$ locate libGL
/home/rudy/opt/android/android-sdk-linux/tools/lib/libGLES_CM_translator.so
/home/rudy/opt/android/android-sdk-linux/tools/lib/libGLES_V2_translator.so
/usr/lib/i386-linux-gnu/libGLU.so.1
/usr/lib/i386-linux-gnu/libGLU.so.1.3.1
...
/usr/lib32/nvidia-current/libGL.so.304.43

b) Create the soft link

sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 /usr/lib/libGL.so

Comments: use a 64-bit library on a 64-bit operating system!

Now start the emulator My system is Optimus, and I have installed Bumblebee. I can use "Intel Open Source Technology Center" "Mesa DRI Intel(R) Ironlake Mobile " "2.1 Mesa 9.0" or "NVIDIA Corporation" "GeForce GT 330M/PCIe/SSE2" "3.3.0 NVIDIA 304.43".

a) Intel

/home/rudy/tests/android/adt-bundle-linux-x86_64/sdk//tools/emulator64-arm -avd avd_42 -scale 0.46 -gpu on -verbose

b) Nvidia

optirun /home/rudy/tests/android/adt-bundle-linux-x86_64/sdk//tools/emulator64-arm -avd avd_42 -scale 0.46 -gpu on -verbose

Comments:

  • I didn't see any difference between the Intel and the Nvidia cards... It is certainly because the emulator is not GPU intensive.
  • On my system an Intel Core i5, it took almost 1 minute to start the emulator... Please be patient... I find the emulator rather fast after it is loaded (the 1 minute to wait). If you start the emulator from the Eclipse IDE, then the emulator does a software emulation (the GPU is off) and took 1 min 30 to start... It is much more slower than using the Intel or Nvidia cards!!!
  • verbose is the parameter to use to display more diagnostics
  • optirun is the command to make use of the Nvidia on Bumblebee. If you don't have Bumblebee don't use it!
  • avd is a virtual device
  • gpu on to make use of the graphical card

Solution 14 - Android

On Ubuntu 64 bit,

1. Check libGL,

$ locate libGL.so
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0

2. Create a symlink where the SDK is installed

ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/local/android-studio/sdk/tools/lib/libGL.so

Solution 15 - Android

OSError: libGL.so: cannot open shared object file: No such file or directory

It may appear on Linux systems when you try to launch VNL for the first time. To solve it, create (as administrator) a new link in /usr/lib :

sudo ln -s /usr/lib/libGL.so.1.2 /usr/lib/libGL.so

If you have a 64-bit Linux, use /usr/lib64 instead .

First check that you actually have libGL.so.1.2 in /usr/lib or /usr/lib64 ; it might be called libGL.so.1 or something else instead, or located in another directory, depending on the video drivers.

You can use locate libGL to find the correct file to link to.

Solution 16 - Android

Similar to user1289608, I was able to do a sym link from an existing install of Mesa:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so

Solution 17 - Android

I had the same issue. But in my case, I solved it another (I think, better) way.

In my situation (Lubuntu 13.10), it was enough to simply also install the library libgl1-mesa-dev through Synaptic Package manager (the libgl1-mesa-dri library was already installed by default when the Lubuntuu distro was set up).

That solves all the hassle of putting links from one file to the other and also prevents polluting your system:

  • How will you know after several months (or years) what dedicated links you've put to keep the system running?
  • What about a future updates, if you start to do those things yourself? Will something be broken/not updated due to "manual intervention"?

If you use the "system mechanism", it's all done for you. And correctly done. That's why those tools are there in the first place.

Best rgds,

Solution 18 - Android

I am using Ubuntu 12.04 64-bit. Linking /usr/lib64/libGLC.so.0 to /usr/lib64/libGL.so seems to solve the problem.

EDIT: It stops the error messages, but the emulator is still slow for me.

Solution 19 - Android

This worked for me:

Restart the adb from the DDMS:
In Eclipse: Window > Open Perspective... > Other > DDMS. Select the emulator from the left side pane and select "Restart adb"

You can also restart the adb server from the terminal window.

android-sdk-linux/platform-tools/adb kill-server
android-sdk-linux/platform-tools/adb start-server

Solution 20 - Android

I had the same problem. Reinstalling the Nvidia driver fixed the segmentation fault for me.

Solution 21 - Android

I found the folder for libGL by the command "locate"

It turned out to be in /usr/lib/i386-linux-gnu/

> ~$ locate libGL
/usr/lib/i386-linux-gnu/libGLEW.so.1.8
/usr/lib/i386-linux-gnu/libGLEW.so.1.8.0
/usr/lib/i386-linux-gnu/libGLEWmx.so.1.8
/usr/lib/i386-linux-gnu/libGLEWmx.so.1.8.0
/usr/lib/i386-linux-gnu/libGLU.so.1
/usr/lib/i386-linux-gnu/libGLU.so.1.3.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0

Solution 22 - Android

For my Debian 7 'Wheezy' installation I used the following command:

ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 opt/android/tools/lib/libGL.so

Solution 23 - Android

sudo apt-get install libgl1-mesa-dev
cd ~/Development/adt-bundle-linux-x86_64-20140321/sdk/tools/lib
unlink libGL.so 
ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 libGL.so

that's it!

Solution 24 - Android

I had this problem because I had checked "Use Host GPU" when creating my AVD. I tried it with that option unchecked and I was able to successfully start the emulator. This is acceptable for my testing purposes, but if using the host GPU is important you'll probably want to try some of the other solutions here.

Solution 25 - Android

I solved this problem by reinstalling libgl1, both the 64- and 32-bit libraries:

$ sudo apt-get install --reinstall libgl1-mesa-glx libgl1-mesa-glx:i386

Background: Previously I switched from the free radeon driver back to fglrx. I guess this somehow screwed up my libgl1, because fglrx comes with its own version.

Besides, I think that the other solutions provided here are possibly dangerous, because it is wrong to symlink 32 bit shared libraries into the (64 bit) /lib/ directory.

Solution 26 - Android

Check if you have libgl1-mesa-* packages installed. If so, install the libgl1-mesa-dev package to get the unversioned shared objects.

You shouldn't have to do this -- it's the Android team's error. Give them a break, they're only Java developers.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionphp.khanView Question on Stackoverflow
Solution 1 - Androiduser1410657View Answer on Stackoverflow
Solution 2 - AndroidliboView Answer on Stackoverflow
Solution 3 - Androiduser1289608View Answer on Stackoverflow
Solution 4 - AndroidWood DragonView Answer on Stackoverflow
Solution 5 - AndroidFrank AFRIATView Answer on Stackoverflow
Solution 6 - AndroidinderView Answer on Stackoverflow
Solution 7 - Androidsergio91ptView Answer on Stackoverflow
Solution 8 - AndroidmarcantonioView Answer on Stackoverflow
Solution 9 - AndroidgridstationView Answer on Stackoverflow
Solution 10 - Androiduser1860888View Answer on Stackoverflow
Solution 11 - AndroidjAbreuView Answer on Stackoverflow
Solution 12 - AndroidKevin ZhuView Answer on Stackoverflow
Solution 13 - AndroidRudy VissersView Answer on Stackoverflow
Solution 14 - AndroidprayagupaView Answer on Stackoverflow
Solution 15 - AndroidDipaliView Answer on Stackoverflow
Solution 16 - AndroidkcstromView Answer on Stackoverflow
Solution 17 - AndroidGeertVcView Answer on Stackoverflow
Solution 18 - Androidglen3bView Answer on Stackoverflow
Solution 19 - AndroidanirusView Answer on Stackoverflow
Solution 20 - AndroidmaegnorView Answer on Stackoverflow
Solution 21 - AndroidcootjeView Answer on Stackoverflow
Solution 22 - AndroidSileriaView Answer on Stackoverflow
Solution 23 - Androiduser1090003View Answer on Stackoverflow
Solution 24 - AndroidBen JakubenView Answer on Stackoverflow
Solution 25 - AndroiddmoebiusView Answer on Stackoverflow
Solution 26 - AndroidRyanView Answer on Stackoverflow