Skip to content

Build Guide

Daniel Zhang edited this page Nov 28, 2016 · 1 revision

Dependencies

  • automake
  • libtool
  • curses
  • readline
  • zlib

Quick Build

  1. Clone the PhxSQL repository: git clone https://github.com/tencent-wechat/phxsql.git.
  2. Run the script build.sh under the root of repository, this would build everything if all goes well. (will take a lone time, don't panic)

If build.sh failed, you might follow the step-by-step guide below.

Get Sources

git clone --recursive https://github.com/tencent-wechat/phxsql.git.

Use the parameter --recursive to fetch third-party libraries glog, leveldb andprotobuf, as well as phxpaxos, phxrpc and colib. You can also download those libraries by yourself, then place them under third_party.

Auto-install All Third-party Libraries

  1. cd third_party.
  2. ./autoinstall.sh.
  3. You may see all done. if everything install successfully, then you can skip to Build PhxSQL.

If autoinstall.sh failed, check which library is failed to be built and try to fix it. You may need to follow guides below to build each library one by one.

Build leveldb

Our build guide base on leveldb 1.19, steps may be different if you download other versions.

  1. cd third_party/leveldb.
  2. make, this would build libleveldb.a under the out-static directory.
  3. mkdir lib, then cd lib;ln -s ../out-static/libleveldb.a libleveldb.a to create a symbolic link, PhxSQL will search the library under lib.

Build protobuf

  1. cd third_party/protobuf.
  2. ./autogen.sh. (This would download gmock but the link in script has broken, you may need to download by yourself, or copy from phxpaxos: cp -r ../phxpaxos/third_party/gmock gmock. If autoreconf or AC_PROG_LIBTOOL missing, you should install automake and libtool.)
  3. ./configure CXXFLAGS=-fPIC --prefix=$(pwd), CXXFLAGS and --prefix must be set correctly.
  4. make && make install.
  5. Check directories bin, include and lib have been created after build completed successfully.

You can also read the protobuf build guide

Build glog

  1. cd third_party/glog.
  2. ./configure CXXFLAGS=-fPIC --prefix=$(pwd), CXXFLAGS and --prefix must be set correctly.
  3. make && make install.
  4. Check directory lib has been created, and libglog.a exist under lib.

Build colib

  1. cd third_party/colib.
  2. make.
  3. Check directory lib has been created, and libcolib.a exist under lib.

Build phxpaxos

  1. cd third_party/phxpaxos/third_party.
  2. phxpaxos also depend on glog, leveldb and protobuf, since we had built them already, it's no need to build them again.
  3. rm -rf glog leveldb protobuf remove these directories.
  4. ln -s ../../glog glog symbolic link to the glog directory we already built.
  5. ln -s ../../leveldb leveldb.
  6. ln -s ../../protobuf protobuf.
  7. cd .. back to the root of phxpaxos.
  8. ./autoinstall.sh.
  9. make && make install.
  10. Check directory lib has been created, and libphxpaxos.a exist under lib.
  11. cd plugin; make && make install build the paxos plugin.
  12. Check directory lib has been created, and libphxpaxos_plugin.a exist under lib.

Build phxrpc

  1. cd third_party/phxrpc/third_party.
  2. phxrpc depend onprotobuf, since we had built it already, it's no need to build it again.
  3. rm -rf protobuf.
  4. ln -s ../../protobuf protobuf.
  5. cd .. back to the root of phxpaxos.
  6. make.
  7. Check directory lib has been created, and libphxrpc.a exist under lib.

Build PhxSQL

  1. Download the source code of percona percona-server-5.6.31-77.0.tar.gz, Please note that only percona-server-5.6_5.6.31-77.0 could be used.
  2. Decompress it under the root of PhxSQL source, rename it to percona.
  3. cd into the root of PhxSQL source.
  4. ./autoinstall.sh. (If you see Curses library not found or Cannot find system readline libraries, libraries curses and readline are need to be installed)
  5. make && make install. (will take a lone time, don't panic)
Clone this wiki locally