赞
踩
本文演示在Linux中编译安装Crow
下载源码
git clone https://github.com/CrowCpp/Crow.git
创建build目录
mkdir build && cd build
编译
cmake .. -DCROW_BUILD_EXAMPLES=OFF -DCROW_BUILD_TESTS=OFF
安装
make install
// main.cpp
- #include <crow.h>
-
- int main(){
- crow::SimpleApp app;
- CROW_ROUTE(app, "/")([](){
- return "Hello world";
- });
- app.port(8080).multithreaded().run();
- }
// CMakeLists.txt
- cmake_minimum_required(VERSION 3.10)
- project(MyCrowProject)
-
- # 设置 C++ 标准
- set(CMAKE_CXX_STANDARD 11)
- set(CMAKE_CXX_STANDARD_REQUIRED True)
-
- # 查找 Crow 库并包含其头文件路径
- find_package(Crow CONFIG REQUIRED)
-
- # 添加可执行文件并链接 Crow 库
- add_executable(MyCrowApp main.cpp)
- target_link_libraries(MyCrowApp PRIVATE Crow::Crow)
编译测试
mkdir build && cd build && cmake .. && make && ./MyCrowApp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。