bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Bazel does not build on out-of-the-box Ubuntu Utopic (14.10)

Open collinw opened this issue 11 years ago • 1 comments

I created a fresh Google Compute Engine VM based on Ubuntu 14.10, then ran the commands from http://bazel.io/docs/install.html to install necessary dependencies. This was done against Bazel commit 087df302dbda12212788d59162cc946fda037081.

Actually running ./compile.sh failed like so:

$ ./compile.sh 
INFO: You can skip this first step by providing a path to the bazel binary as second argument:
INFO:    ./compile.sh build /path/to/bazel
🍃  Building Bazel from scratch.......
Compiling JNI libraries...
g++ -I . -I /usr//include/ -I /usr//include/linux -std=c++0x -fPIC -c -D_JNI_IMPLEMENTATION_ -DBLAZE_JAVA_CPU="k8" 
-DBLAZE_OPENSOURCE=1 -o /tmp/bazel.OxB1Dmr9/native/md5.cc.o src/main/cpp/util/md5.cc
In file included from /usr/include/c++/4.9/cwchar:44:0,
                 from /usr/include/c++/4.9/bits/postypes.h:40,
                 from /usr/include/c++/4.9/bits/char_traits.h:40,
                 from /usr/include/c++/4.9/string:40,
                 from ./src/main/cpp/util/md5.h:21,
                 from src/main/cpp/util/md5.cc:40:
/usr/include/wchar.h:151:38: error: ‘size_t’ has not been declared
     const wchar_t *__restrict __src, size_t __n)

AFAICT where I ran into trouble is with these instructions: "Otherwise, find the Java bin directory using which javac", which on Ubuntu yields /usr/bin/javac. If I following the instructions and use export JAVA_HOME=/usr, then /usr/include/linux ends up on the include path, which is no good.

What you actually want is to follow two levels of symlink indirection (/usr/bin/javac -> /etc/alternatives/javac -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javac) and obtain a JAVA_HOME of /usr/lib/jvm/java-7-openjdk-amd64/. Running ./compile with that value of JAVA_HOME produced a working Bazel binary.

collinw avatar Jun 30 '15 01:06 collinw

from https://github.com/google/bazel/blob/master/scripts/bootstrap/compile.sh#L80 the code should work without setting JAVA_HOME (I had a pristine Ubuntu 15.04 with the exact same set-up for java and it worked out of the box). I will try to make the installation instructions clearer.

damienmg avatar Jun 30 '15 08:06 damienmg