zoukankan      html  css  js  c++  java
  • 腾讯开源项目phxpaxos的编译步骤

    #paxos的一般编译流程在项目文档《中文详细编译手册》里面已经有介绍,这里重点介绍一下编译samples目录下的代码;

    #我的环境是ubuntu;

    #设置paxos根目录

        phx_dir=~/code/tencent/phxpaxos/

    #编译leveldb

        cd $phx_dir/third_party/leveldb

        make

        mkdir lib

        cd lib

        ln -s ../libleveldb.a libleveldb.a

    #编译protobuf

        cd $phx_dir/third_party/protobuf

        ./autogen.sh

        ./configure CXXFLAGS=-fPIC --prefix=`pwd`

        make && make install

    #编译glog

        cd $phx_dir/third_party/glog

        ./configure CXXFLAGS=-fPIC -prefix=`pwd`

        make && make install

       

    #有时候我们在phxpaxos代码里面改了东西,但是sample工程不能生效,

    #所以我们在编译 libphxpaxos.a 和 libphxpaxos_plugin.a 的时候先删掉之前的静态库

    #然后在编译 sample 代码的时候先执行一下 make clean

    #编译phxpaxos静态库

        cd $phx_dir

        find ./ -name "libphxpaxos.a" | xargs rm

        find ./ -name "libphxpaxos_plugin.a" | xargs rm

        ./autoinstall.sh

        make debug=y && make install

        ll lib/

    #编译PhxPaxos Plugin静态库

        cd $phx_dir/plugin

        make && make install

        ll ../lib

       

    #编译gtest和gmock

        cd $phx_dir/third_party

        rm -rf googlemock

        git clone --recursive https://github.com/google/googletest.git

        cd googletest

        cmake -DCMAKE_INSTALL_PREFIX=`pwd` .

        make && make install

        cd $phx_dir/third_party/

        mkdir gmock

        mv googletest/{include,lib} ./gmock

        cd gmock

        mv lib64 lib

    #grpc依赖于openssl,请下载最新的openssl并编译安装

        openssl编译步骤略

        grpc依赖于openssl,如果有 libssl.a 链接错误,请下载最新的openssl并编译安装

        附错误提示:

        [LD] Linking third_party/grpc/libs/opt/libgrpc.so.7.0.0-dev

        /usr/bin/ld: /usr/local/lib/libssl.a(t1_meth.o): relocation R_X86_64_32 against .rodata can not be used when making a shared object; recompile with -fPIC

        /usr/local/lib/libssl.a: error adding symbols: Bad value

       

    #编译grpc

        cd $phx_dir/third_party/

        git clone --recursive https://github.com/grpc/grpc.git

        make

        mkdir bin

        cp -rf bins/* bin/

        mkdir lib

        cp -rf libs/* lib/

        cp -rf libs/opt/* lib/

       

    #把grpc的路径加到环境变量

        export PATH=$phx_dir/third_party/grpc/bins/opt/:$phx_dir/third_party/grpc/bins/opt/protobuf:$PATH

        which grpc_cpp_plugin

        which protoc

    #编译例子

        cd $phx_dir/sample

        make

    #修改代码之后的快速重编

    killall phxecho

    phx_dir=~/code/tencent/phxpaxos/

    cd $phx_dir

    find ./ -name "libphxpaxos.a" | xargs rm

    find ./ -name "libphxpaxos_plugin.a" | xargs rm

    ./autoinstall.sh

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    make debug=y && make install

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    ll lib/

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    cd $phx_dir/plugin

    make && make install

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    ll ../lib

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    phx_dir=~/code/tencent/phxpaxos/

    cd $phx_dir/sample/phxecho

    make clean

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    make

        if [ $? -ne 0 ]; then    echo "[error]";   sleep 365d; fi

    #运行例子

    phx_echo_dir=~/code/tencent/phxpaxos/sample/phxecho/

    cd $phx_echo_dir

    mkdir -p log1/log

    mkdir -p log2/log

    mkdir -p log3/log

    server_1=127.0.0.1:38001

    server_2=127.0.0.1:38002

    server_3=127.0.0.1:38003

    cd $phx_echo_dir/log1 && rm -r log* && mkdir log

    $phx_echo_dir/phxecho $server_1 $server_1,$server_2,$server_3

    cd $phx_echo_dir/log2 && rm -r log* && mkdir log

    $phx_echo_dir/phxecho $server_2 $server_1,$server_2,$server_3

    cd $phx_echo_dir/log3 && rm -r log* && mkdir log

    $phx_echo_dir/phxecho $server_3 $server_1,$server_2,$server_3

    #可以在代码里面加点日志打印

        //lijing-tets

        PLImp("lijing-test, Instance :: OnTimeout, %d ", 222);

  • 相关阅读:
    GHOJ 683 小球
    GHOJ 682 图的m着色问题
    GHOJ 681 最佳调度问题
    YBT 最长公共子上升序列
    YBT 数的划分
    Educational Codeforces Round 68 (Rated for Div. 2) C
    马里奥项目中对象直接通讯小结
    Educational Codeforces Round 67 (Rated for Div. 2) C
    19新疆省赛总结
    Codeforces Round #560 div3 (C,D)
  • 原文地址:https://www.cnblogs.com/lijingshanxi/p/10089351.html
Copyright © 2011-2022 走看看