无法编译 Crow 示例 - boost/optional.hpp: 没有这样的文件或目录

Can't compile a Crow sample - boost/optional.hpp: No such file or directory

我想在 Debian 中编译和测试 Crow C++ 微框架 Linux 11:

  1. 下载最新的crow.deb,目前crow-v1.0+1.deb

  2. 安装它:

    $ sudo dpkg -i crow-v1.0+1.deb
    Selecting previously unselected package crow.
    (Reading database ... 587955 files and directories currently installed.)
    Preparing to unpack crow-v1.0+1.deb ...
    Unpacking crow (1.0+1) ...
    Setting up crow (1.0+1) ...
    
  3. 使用 crowcpp.org:

    中的示例代码创建一个 .cpp 文件
    $ echo '#include "crow.h"
    
    int main()
    {
        crow::SimpleApp app;
    
        CROW_ROUTE(app, "/")([](){
            return "Hello world";
        });
    
        app.port(18080).run();
    }' > crowtest.cpp
    
  4. 尝试编译:

    $ g++ crowtest.cpp -lpthread
     In file included from /usr/include/crow.h:2,
                      from crowtest.cpp:1:
     /usr/include/crow/query_string.h:9:10: fatal error: boost/optional.hpp: No such file or directory
         9 | #include <boost/optional.hpp>
           |          ^~~~~~~~~~~~~~~~~~~~
     compilation terminated.
    
  5. 见上面的错误。如何编译 Crow 示例代码?

您需要安装 Boost,对于 Debian,这将是 apt install libboost-dev