Tuesday, January 15, 2013

Google NativeClient on Ubuntu

Initially I tried installing NativeClient (NaCl) on a Ubuntu 32bit VM, but some NaCl tests failed saying specific CPU features needed for NaCl are not available. But later on when setting up a 64bit Ubuntu VM I had to enable Intel VT-X features in BIOS, and this seemed to enable 64bit VM to pass NaCl tests.

Installing NaCl on a 32bit Ubuntu:
Follow the instructions here to download NaCl source using gclient/depot tools: http://code.google.com/p/nativeclient/wiki/Source?tm=4

Once you download everything to nativeclient, you need to run:
make

I had to install g++ libraries too:
sudo apt-get install g++

make failed with some errors:
#include<gelf.h> was throwing an error saying gelf.h was not found.

Installing gelf and libelf did not help.
- sudo apt-get install gelf
- installing libelf from Software center

I had to install libelf-dev from the Ubuntu software center, then the make succeeded.

After make, go to native_client sub directory and run
./scons MODE=opt-linux,nacl
Compiling was successful.
When testing NaCl, just try small_tests, medium_tests and large_tests. run_all_tests argument has some tests specific for 64bit linux, and hence is supposed to fail.

Installing NaCl on a 64bit Ubuntu:
Most of the instructions are same as for 32 bit. When doing a make, I got this error:
make: *** [out/Debug/obj/gen/tc_newlib/lib32/crti.o] Error 1

As per this post: https://groups.google.com/forum/#!topic/native-client-discuss/NJZ2JKWCCCY
we need to install the capability to run x86_32 binaries on a x86_64 machine.

So I had to install :
sudo apt-get install ia32-libs

Then make threw another error:
bits/predefs.h: No such file or directory

This thread gives the solution: http://ubuntuforums.org/showthread.php?t=1877944
we need 32bit libc. We can get it using:
sudo apt-get install libc6-dev-i386

I then got this error:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++

As per this link, i had to install "g++-multilib"
http://ubuntuforums.org/archive/index.php/t-1604953.html
sudo apt-get install g++-multilib


run_all_tests  does not work unless you put platform=x86-64 as argument for scons

I had to install python-dev package when giving platform=x86-64 for scons.

No comments:

Post a Comment