WEB实战手册-基于C++(1)

发布时间 2023-08-11 18:54:37作者: 水宝石

目录

oat++

oat++ 是一个轻量级高性能 Web 服务开发框架,采用纯 C++ 编写而成。

  • 特性:
  1. 特性快速
    
  2. 零依赖
    
  3. 异步服务器,高性能,在单个服务器上同时处理超过 500 万个 WebSocket 连接
    
  4. 多线程服务器(简单的 API)
    
  5. 连接无感知,可以使用任何传输类型,无论是 SSL 后端、套接字、管道还是文件,它只关心 HTTP 流
    
  6. REST 框架,并可自动生成文档:oatpp-swagger
    
  7. 类 Retrofit 客户端 wrapper
    
  8. 对象映射,快速对象序列化与反序列化,目前是 JSON,很快会支持更多格式
    
  9. 简单的依赖注入框架
    
  10. 简单的测试框架
    
  • 支持平台:

以下面两个平台为主:
Unix/Linux
Windows

  • 编译

需要以下软件包

  1. Git
    
  2. C++ compiler supporting C++ version >= 11.
    
  3. Make
    
  4. CMake version >= 3.1
    
$ yum install git
$ yum install cmake
$ yum install gcc gcc-c++ make
$ yum install libatomic

从源码安装

$ git clone https://github.com/oatpp/oatpp.git
$ cd oatpp/

$ mkdir build && cd build

$ cmake ..
$ make install

编译选项

选项                                  默认     描述
CMAKE_BUILD_TYPE 	Debug 	Build type.
BUILD_SHARED_LIBS 	OFF 	Leave this option to OFF. Oat++ is meant to be used as a static library.
OATPP_BUILD_TESTS 	ON 	Set it to OFF to disable tests build.
OATPP_LINK_ATOMIC 	OFF 	Explicitly link libatomic. This flag is ignored for: MSVC, MINGW, APPLE, FreeBSD.
OATPP_DISABLE_ENV_OBJECT_COUNTERS 	OFF 	If ON, do not count oatpp objects (do not detect memory-leaks). This will increase performance.
Note: DO NOT use this flags to build/run application tests, as tests won't detect memory-leaks.
OATPP_DISABLE_POOL_ALLOCATIONS 	OFF 	If ON, do not use oatpp memory-pools.
OATPP_COMPAT_BUILD_NO_THREAD_LOCAL 	OFF 	Build without thread_local feature. 
  • hello,world