Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 1.55 KB

README_bak.md

File metadata and controls

92 lines (66 loc) · 1.55 KB

C++ Project

  • 整理了一些使用CMake 管理的样例代码,所有使用到的库都需要手动安装到本地,比如leveldbduckdb

构建生成器文件时可选参数

  • 如果需要学习第三方库,在编译安装时使用debug模式。
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=/your/install/path
-DCMAKE_CXX_STANDARD=11

常用开源库

  • google test
  • leveldb
  • duckdb
  • arrow
  • crc
  • catch2
  • abseil
  • folly
  • spdlog
  • picobench

依赖说明

  • 第三方库需要先安装,建议安装到指定目录下,直接删除就相当于卸载,若安装时没指定安装目录,默认安装如下:
  • 所有头文件都放在/usr/local/include目录下
  • 所有静态库都放在/usr/local/lib目录下

编译

# build是编译时创建的目录
cd leveldb
cmake -B build
cmake --build build

指定安装路径

cmake -DCMAKE_INSTALL_PREFIX=/your/install/path ..

安装

sudo cmake --install build

添加库文件

include_directories(/usr/local/include)
find_library(LIBS  leveldb /usr/local/lib)
add_executable(leveldb_test leveldb_test.cpp)
target_link_libraries(leveldb_test ${LIBS})

fetch_content

在Linux环境可以正常运行,在Mac环境存在链接错误

folly

依赖库特别多,在Mac上直接使用homebrew安装

brew install folly

在使用folly时需要引入的库包括

  • boost
  • libevent
  • gflags
  • fmt
  • glog
  • double-conversion

picobench输出报告

./picobench_test --output=report.txt