• ubuntu 安装 evpp


    ubuntu 安装 evpp

    来源 https://www.cnblogs.com/wisdomyzw/p/9402440.html

    Ubuntu虚拟机安装开源库evpp说明:

    EVPP为奇虎360基于libevent开发的现代化的支持C++11特性的高性能网络库,自带TCP/UDP/HTTP等协议的异步非阻塞式的服务器和客户端库。拥有如下特性:

    * 现代版的C++11接口
    * 非阻塞异步接口都是C++11的functional/bind形式的回调仿函数(不是libevent中的C风格的函数指针)
    * 非阻塞纯异步多线程TCP服务器/客户端
    * 非阻塞纯异步多线程HTTP服务器/客户端
    * 非阻塞纯异步多线程UDP服务器
    * 支持多进程模式
    * 优秀的跨平台特性和高性能(继承自libevent的优点)

    evpp的编译需要依赖如下动态库, 分别介绍如下:

    libevent  glog  gtest  gflags  boost evpp

    linevent:
     1、window访问: http://libevent.org/libevent-2.0.22.tar.gz, 拷贝到linux机器上
     (或者了Linux wget http://libevent.org/libevent-2.0.22.tar.gz)
     2、tar -zxvf libevent-2.0.22-stable.tzr.gz
     3、cd libevent-2.0.22-stable
     4、./configure --prefix=/usr
     5、make
     6、sudo make install
     7、检查是否安装成功, ls -al /usr/lib | grep libevent  
     

    glog:
     1、下载源码: git clone https://github.com/google/glog
     (git clone下载慢可以参考:
      ubuntu上解决访问github慢的方法:
      1、进入终端命令行模式,输入sudo vi /etc/hosts
      2、输入i进入编辑命令,英文输入法输入G,vim编辑器跳到hosts文件的最后一行
      3、用浏览器访问 IPAddress.com 使用 IP Lookup 工具获得github.com和github.global.ssl.fastly.net域名的ip地址
      4、在vi打开的hosts文件中添加如下格式:
       192.30.253.112 github.com
       151.101.44.249  github.global.ssl.fastly.net
      5、esc退出编辑模式,输入:wq,保存hosts文件,修改hosts结束
      6、更新DNS缓存,输入sudo /etc/init.d/networking restart
     )
     2、配置: sudo apt-get install autoconf automake libtool
     3、编译安装:
      进入源码根目录(glog文件夹)
      ./autogen.sh
      ./configure
      make -j 24
      sudo make install
     

    gflags:
     1、下载源码:git clone https://github.com/gflags/gflags
     2、编译安装:
      进入源码目录(即gflags文件夹)
      cmake .
      make -j 24
      sudo make install  
     

    gtest:
     1、安装源代码:sudo apt-get install libgtest-dev
     2、编译源代码:
      cd /usr/src/gtest
      $ sudo mkdir build
      $ cd build
      $ sudo cmake ..
      $ sudo make
     3、拷贝生成的库到系统目录下(将生成的libgtest.a 和 libgtest_main.a 拷贝到系统的lib路径下.):
      $ sudo cp libgtest*.a /usr/local/lib
     

    boost:
     使用apt-get直接进行安装: sudo apt-get install libboost-dev
      (这个安装成功了,但是使用失败,应该是包不全,没有boost_system与boost_thread等)
      
     1、下载安装包源码:
      https://www.boost.org/users/download/
     2、解压编译:
      tar -zxvf boost_1_67_0.tar.gz
      cd boost_1_67_0
      ./bootstrap.sh(不用加 --prefix=dir,会默认安装到/usr/local/目录下,成功会生成b2可执行文件)
      
      sudo ./b2 install(时间较长,20分钟) 
     

    evpp:
     1、下载源码与子模块源码:
      $ git clone https://github.com/Qihoo360/evpp
      $ cd evpp
      $ git submodule update --init --recursive
     2、编译源码:
      $ mkdir -p build && cd build
      $ cmake -DCMAKE_BUILD_TYPE=Debug ..
      $ make -j(不需要并行编译,直接make就好了,我用make -j的时候虚拟机挂了两次)
     3、运行用例:
      $ make test(这个会跑unittest用例,需要3~5分钟后)
      $ cd evpp/build/bin
      * Run a HTTP client example:
      

      $ ./example_http_client_request01
      WARNING: Logging before InitGoogleLogging() is written to STDERR
      I0306 11:45:09.464159 13230 inner_pre.cc:37] ignore SIGPIPE
      I0306 11:45:09.464896 13230 client01.cc:30] Do http request
      I0306 11:45:09.493073 13231 client01.cc:14] http_code=200 [ok]
      I0306 11:45:09.493124 13231 client01.cc:16] HTTP HEADER Connection=close
      I0306 11:45:09.493242 13231 event_loop.cc:103] EventLoop is stopping now, tid=140722561709824
      I0306 11:45:09.993921 13231 event_loop.cc:93] EventLoop stopped, tid: 140722561709824
      I0306 11:45:09.994107 13230 client01.cc:38] EventLoopThread stopped.

      *** Run a HTTP server example:
        $ ./example_httpecho
      WARNING: Logging before InitGoogleLogging() is written to STDERR
      I0306 12:15:31.703927 21228 inner_pre.cc:37] ignore SIGPIPE
      I0306 12:15:31.706221 21228 http_server.cc:99] http server is running
      *** And in another console(模拟客户端,要在服务器运行的时候):
        $ curl "http://127.0.0.1:9009/echo" -d "Hello, world"
        ello, world

      *Run a TCP echo server example:
         $ ./example_tcpecho
      * And in another console(模拟客户端,要在服务器运行的时候):
        $ telnet 127.0.0.1 9099
      Trying 127.0.0.1...
      Connected to 127.0.0.1.
      Escape character is '^]'.

    ================= End

  • 相关阅读:
    (OK) angular2-data-table is a Angular2 component for presenting large and complex data.
    Table pagination and Search bar in Angular2
    Angular 2 Tutorial: Create a CRUD App with Angular CLI and TypeScript
    Angular 2 CRUD application using Nodejs
    kernel 3.10内核源码分析--BUG_ON流程
    Protecting Routes using Guards in Angular 2
    Angular 2 User Registration and Login Example & Tutorial
    dmidecode
    (half OK) 在VirtualBox中运行 cm-13-kiwi (华为 荣耀 5X)
    Linux基金会宣布成立OpenSDS组织,应对存储云化转型
  • 原文地址:https://www.cnblogs.com/lsgxeva/p/10718979.html
Copyright © 2020-2023  润新知