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導致的錯誤,請跳過
<blockquote>
報錯:
./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
</blockquote>

我使用的docker,這一步編譯的時間有點長,但最終編譯成功。

在seastar同級目錄新建目錄myseastar,並在目錄下新建文件getting-started.cc

#include "core/app-template.hh"
#include "core/reactor.hh"
#include <iostream>
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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM