描述:在mips上使用tensorflow,面临必须编译源码,编译之前不得不编译tensorflow依赖的编译器bazel.本人试过cmake编译bazel(但由于最终会用docker编译,无疑这方法行不通),无赖之下只能执行 compile.sh文件进行编译,期间各种水坑,在探索编译了10天后,终于编译成功,记录此博客,方便更多只能使用源码编译的同路人。
本人的环境:
[xzy@localhost test]$ uname -aLinux localhost.localdomain 3.10.84-11.fc21.loongson.mips64el
#1 SMP PREEMPT Mon Dec 5 13:54:03 CST 2016 mips64 mips64 mips64 GNU/Linux
具体可以参看src/README.md文件To build protobuf from source, the following tools are needed:
* autoconf
* automake
* libtool
* curl (used to download gmock)
* make
* g++
* unzip
注意:非最新版本的protocbuf在执行autogen.sh可能会出现上不了google下载不了gmock,将本文件的curl处的修改如下即可
- curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
+ curl $curlopts -L -o gmock-1.7.0.zip https://github.com/peter-wangxu/gMock/archive/1.7.0.zip
$git clone https://github.com/google/protobuf.git
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
说明:如果你要源码编译bazel,不要使用git clone https://github.com/bazelbuild/bazel.git. 克隆的文件里少了protocbuf相关的文件,会报GRPC_JAVA_PLUGIN PROC找不到的错误,编译GRPC_JAVA_PLUGIN 始终编译不过,浪费许多时间。最后问了[email protected] 才了解这个坑,一定一定一定要下载xxx-dist.zip包
$wget https://github.com/bazelbuild/bazel/releases/download/0.5.0/bazel-0.5.0-dist.zip
$mkdir bazel-0.5.0
$cp bazel-0.5.0-dist.zip
$cd bazel-0.5.0
$unzip bazel-0.5.0-dist.zip
说明:由于篇幅原因,部分文件看本人的github链接
export PROTOC=/usr/local/bin/protoc
export JAVA_HOME="/opt/j2sdk-image"
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:/usr/local/bin/:$PATH
export JAVA_OPTS="-server -Xms2048m -Xmx2048m"
export TMPDIR=/home/xzy/bazel_tmp_output
说明:出现build successful 字样,就说明编译成功。进一步,会在output下生成一个bazel二进制文件,可以执行output/bazel version验证
[root@localhost output]# ./bazel version
Extracting Bazel installation...
............................................
Build label: 0.5.0-2017-06-01 (@2e9fff0)
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: 星期四 六月 1 01:57:44 2017 (1496282264)
Build timestamp: 1496282264
Build timestamp as int: 1496282264
https://svnweb.freebsd.org/ports/head/devel/bazel/files/patch-scripts_bootstrap_bootstrap.sh?revision=436446&view=markup
https://github.com/bazelbuild/bazel/issues/1955#issuecomment-305157094
https://github.com/bazelbuild/bazel/issues/3068
https://github.com/bazelbuild/bazel/issues/3017
https://github.com/bazelbuild/bazel/issues/1955
https://github.com/bazelbuild/bazel