1 seastar 框架编译hello world

环境 ubuntu16.04:
下载源码:

git clone https://github.com/scylladb/seastar.git
cd seastar
git submodule update --init --recursive

安装依赖:

cd seastar
sudo ./install-dependencies.sh

使用g++-5编译seastar

./configure.py --compiler=g++-5

提示:

Notice: -fsanitize=vptr is broken, disabling; some debug mode tests are bypassed.

这个信息的意思是没有santize,先忽略,继续编译:

ninja

以下内容是之前git clone没有包含submodule导致的错误,请跳过


报错:
./core/print.hh:25:25: fatal error: fmt/ostream.h: No such file or directory
找不到文件fmt/ostream.h,是因为没有安装fmtlib这个包,编译安装:
git clone https://github.com/fmtlib/fmt.git
cd fmt
mkdir build
cd build
sudo apt-get install cmake
cmake ../
make
sudo make install

我使用的docker,这一步编译的时间有点长,但最终编译成功。

在seastar同级目录新建目录myseastar,并在目录下新建文件getting-started.cc

#include "core/app-template.hh"
#include "core/reactor.hh"
#include 
int main(int argc, char** argv) {
    app_template app;
    app.run(argc, argv, [] {
            std::cout << "Hello world\n";
            return make_ready_future<>();
    });
}

编译运行:

g++ `pkg-config --cflags --libs ../seastar/build/release/seastar.pc` getting-started.cc

c++ `pkg-config --cflags --libs ../seastar/build/release/seastar.pc` getting-started.cc

两个命令是一样的,pkg-config是一个用于生产编译选项的工具类.
提示:

WARNING: unable to mbind shard memory; performance may suffer:
WARNING: unable to mbind shard memory; performance may suffer:
Hello world

警告是因为我在docker中运行代码,没有正确的文件系统(ext4 or xfs)

你可能感兴趣的:(1 seastar 框架编译hello world)