1

Tried to Build Firefox OS with Ubuntu 13.10 and got this error:

host SharedLib: libOpenglRender (out/host/linux-x86/obj/lib/libOpenglRender.so)
/usr/bin/ld: cannot find -lX11
/usr/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libOpenglRender.so] Error 1

My system's architecture is x86_64 with GCC 4.6.3

  • Did u managed to build Firefox OS? – blade19899 Dec 23 '13 at 9:32
7

/usr/bin/ld: cannot find -lX11

This means that you are missing the Xserver development libraries. You can install most of them using:

sudo apt-get install xorg-dev

It's also said in the guide:

Requirements for Linux

To build on Linux, you'll need:

[big sip]

X11 headers

  • NOPE nothing like that is required – Sridhar Ramanathan Dec 17 '13 at 17:46
  • 4
    @SridharRamanathan it is. Read the guide again, I added the important parts to my answer. – Braiam Dec 17 '13 at 17:50
  • 1
    @SridharRamanathan and in case you don't understand that the requirements are saying, when it says "headers" it means the development libraries, which is xorg-dev. Sorry to add noise to your post, Braiam, just wanted to add the clarification for the OP. – Thomas Ward Dec 18 '13 at 18:28
4
+50

Before obtaining the code to build Firefox OS, you need a properly configured build system. You can currently build on 64-bit Linux distributions and OS X.

Note: To build Firefox OS onto a phone, begin with your phone NOT connected to your computer. We'll tell you when to plug it in.

Requirements for Linux

To build on Linux, you'll need:

A 64 bit GNU/Linux distribution (Ubuntu 12.04 recommended).
At least 4 GB of RAM/swap space.
At least 20 GB of available hard disk space.

This is more than the bare minimum, but sometimes building fails just because it's missing resources.

You will also need the following tools installed:

  • autoconf 2.13
  • bison
  • bzip2
  • ccache
  • curl
  • flex
  • gawk
  • git
  • gcc / g++ / g++-multilib
  • make
  • OpenGL shared libraries
  • patch
  • X11 headers
  • 32-bit ncurses
  • 32-bit zlib

Emulator build issues

If you are making an emulator build, you need to pay attention to these issues:

First, note that you shouldn't use the x86 emulator — it is hard to install and not well supported.

Next, the build-system for the emulator builds both 32bit and 64bit versions of the emulator. As the emulator depends on OpenGL, this means that you need to have both 32bit and 64bit versions of OpenGL libraries installed on your system. See the discussion in bug 897727.

There are two ways that you can solve this problem:

Solution 1: have both 32bit and 64bit OpenGL libs installed, with the right symlinks

If your linux distro has multilib packages for OpenGL libraries, you can attempt installing them. You might then have to manually create some symlinks.

For example, here is the situation on Ubuntu 12.04 LTS x86-64. On this distribution, the libgl1-mesa-dev package cannot be installed simultaneously in x86-64 and i386 versions, but you can have the following combination of packages simultaneously installed:

sudo apt-get install libgl1-mesa-dev libglapi-mesa:i386 libgl1-mesa-glx:i386

After having run this command, you will still have to manually create some symlinks for the emulator build to succeed:

 sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
 sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Solution 2: just patch the emulator so it only builds 64bit

Just apply this patch to the sdk/ git repository under the B2G repo. This will cause the B2G emulator to only attempt to build the 64bit emulator if you're on a 64bit system, thus avoiding any multilib issues. The 32bit emulator is unused anyway on a 64bit system. This is the simplest solution... until this patch eventually bit-rots.

64 bit requirement installation

Install dependencies

sudo dpkg --add-architecture i386
sudo apt-get update

Once you've completed that, then you can install the necessary packages:

sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git lib32ncurses5-dev lib32z1-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip cmake libxml2-utils

Install adb

The build process needs to pull binary blobs from the Android installation on the phone before building B2G (unless you're building the emulator, of course). For this, you will need adb, the Android Debug Bridge.

You can download and install adb as part of the Android SDK package, for Mac, Linux or Windows - visit the Get the Android SDK page.

Newer Linux distributions have adb already in their repositories. For Ubuntu 12.10 and later, run the following command:

sudo apt-get install android-tools-adb

Install heimdall

Heimdall is a utility for flashing the Samsung Galaxy S2. It's used by the Boot to Gecko flash utility to replace the contents of the phone with Firefox OS, as well as to flash updated versions of B2G and Gaia onto the device. You'll need it if you want to install Firefox OS on a Galaxy S2; it is not needed for any other device. For other devices, we build and use the fastboot utility instead.

Note: Again, it's important to note that this is only required for installing Firefox OS on the Samsung Galaxy S2.

There are two ways to install heimdall:

  • You can download the code GitHub and build it yourself.
    • Use a package manager to install it.
    • On Linux: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev

Configure ccache

The B2G build process uses ccache. The default cache size for ccache is 1GB, but the B2G build easily saturates this; around 3GB is recommended. You can configure your cache by running the following command inside terminal:

ccache --max-size 3GB

For Linux: configure the udev rule for your phone

Note: This section is specific to Linux; Mac OSX has the necessary device permissions set up already.

Next, you need to confingure the udev rule for your phone,

You can get the USB vendor ID by running lsusb with your phone plugged in, but typically it's Google 18d1, Samsung 04e8, ZTE 19d2, Geeksphone/Qualcomm 05c6. Add this line in your /etc/udev/rules.d/android.rules file (replacing XXXX with the ID for your device):

SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", MODE="0666", GROUP="plugdev"

Take ZTE for example, the content in android.rules will be

SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"

If the file doesn't exist, create it. The rules.d directory is usually read only by default, so you may have to use chmod to make the directory writeable, or the file, or both.

Once you've saved the file, and closed it, make the file readable:

sudo chmod a+r /etc/udev/rules.d/android.rules

Now that the udev rules have been updated, restart the udev daemon. For ubuntu:

sudo service udev restart

Finally, unplug and the USB cable but don't replug it in because we need to enable remote debugging on the phone first.

Enable remote debugging

Before you plug your phone back into your USB port, put it USB developer mode. This allows you to debug and flash the phone. To enable developer mode, on your phone select Settings app -> Device information -> More Information -> Developer -> Remote debugging (this was called Developer mode on older versions.) Once the option is checked, remote debugging is enabled, and you are ready to go.

At this point, connect your phone to your computer via a USB cable (if you created the udev rule before, this will trigger udev to detect the phone and create the device node with the right permissions). Now you can check if you can list your device via the adb devices command. If everything has worked ok, you should see an output similar to this (the following is for a Geeksphone Keon):

adb devices
List of devices attached
full_keon       device

If the device did not list as expect, check the file name and the script are all correct (see previous section), then restart the computer and retype the command again. Note also that if your device uses fastboot, the bootloader may identify itself with a different vendor ID than the one you see when the device boots normally.

Backup the phone system partition

Note: You have to do this before you build your device if you do not have existing system backup. Because some libraries will be referenced in build time. These library might be proprietary so we can't provide in our code base.

It is recommended to back up the entire Android system partition on your phone.

You can use this copy of the binary blobs for Android in case you later delete your B2G tree. To do this, run:

adb pull /system <backup target dir>/system

Depending on the phone, you may also need to pull the /data and/or /vendor directories:

adb pull /data <backup target dir>/data
adb pull /vendor <backup target dir>/vendor

If the pull commands fail with "insufficient permission" message, try the following:

  • stop and restart the adb server, or if that fails,
  • double-check that you have granted root permissions to the 'adb' tool within your custom ROM (e.g. under CyanogenMod, change 'Settings -> System -> Developer Options -> Root Access' to 'Apps and ADB' or 'ADB only').
  • Verify that you have set up the udev rule correctly (see For Linux: configure the udev rule for your phone.

On to the next step

At this point, you should be ready to fetch the Firefox OS code!

source

  • Installed all received this new error /usr/bin/ld: cannot find -lGL collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/lib/lib64EGL_translator.so] – Sridhar Ramanathan Dec 17 '13 at 13:29
  • @SridharRamanathan, please follow the now complete guide. If afterwards you have the same problem, i will try and find a fix for you(ps already tried but, couldn't find any). – blade19899 Dec 17 '13 at 14:36
  • I followed more than 5 times and defined new problem askubuntu.com/questions/392105/… PLZ HELP HERE – Sridhar Ramanathan Dec 17 '13 at 14:39
  • @SridharRamanathan, unfortunately i don't have my Ubuntu machine with me, so i cant go in too deeper testing. Will do when i get home. – blade19899 Dec 17 '13 at 14:49
  • 1
    Err... his error is just that he is missing some dependencies. – Braiam Dec 17 '13 at 17:32

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.