c++ - 无法编译 Crow 示例 - boost/optional.hpp : No such file or directory

标签 c++ g++ file-not-found crow

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

  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

关于c++ - 无法编译 Crow 示例 - boost/optional.hpp : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71989024/

相关文章:

ios - 在 xcode 中找不到 SenTestKit 错误

java - 从文件读取时出错

c++ - 为什么我的C++程序崩溃了。我是圆括号的实现问题

c++ - 为什么内存地址是偶数?

c++ - 为什么下面的代码在 MSVC 中不能编译,但在 g++ 中可以编译?

java - grails optaplanner 中解算器配置不存在错误

python - 在 Python 2.7 中编织内联 C++ 代码

c++ - 获取带有 typeid(*this).name 的静态 int 变量类名用于其自己的定义 - C++

linux - 将 SDL2 库与 pkg-config 链接

c++ - Boost 并发库在使用 GNU C++/LLVM C++ 编译时表现不同