boost_log

·
dev no tag September 5, 2022

boost_log

CMakeLists

cmake_minimum_required(VERSION 3.23)
project(BOOSTlog)

set(CMAKE_CXX_STANDARD 23)

set(BOOST_ROOT /Users/peiyilin/env/boost_1_80_0)
set(Boost_NO_SYSTEM_PATHS ON)
find_package(Boost COMPONENTS log thread date_time filesystem REQUIRED)

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})

    MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
    MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
    MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")

    add_executable(${PROJECT_NAME} main.cpp InitLog.cpp InitLog.h ParseINI.cpp ParseINI.h)
    target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES})
endif()
  1. set(Boost_NO_SYSTEM_PATHS ON)是为了设置自定义路径而非默认的盘
  2. -DBoost_DEBUG=ON当cmake找不到boost时可设置编译选项,对应写在cmakelists中是set(Boost_DEBUG ON)

宽字符

现代操作系统中将代码文件和生成文件都指定为utf-8即可,尽量不要去折腾宽字符和窄字符。

链接错误:error LNK2019

编译完成后在项目中使用时,demo中正常但是在项目中直接调用boost可能会造成链接错误,在csdn中是个付费问题,都是搞技术的,何必相互为难呢。

我尝试了几乎所有我能想到的方法,包括用官方对应版本的二进制文件安装,然后制定include路径和lib路径。重新编译所有lib,都无效。

其实最好的办法是查阅boost官方文档。

  1. 下载源码
  2. 编译选项添加该关键字:define=_WIN32_WINNT=0x0A00
  3. Enjoy boost!

我是阅读了文档的How to read the documentation章节的Configuring and building the library小节得到答案的,BOOST_USE_WINAPI_VERSION接口中的_WIN32_WINNT查找对应参数即可。

源码见GitHub

  • 借用boost库实现timer
  • TLE(两行轨道数据)卫星数据格式解析

已有 3 条评论
  1. Jaivova

    buy clomid online australia At the beginning of the 19th century Christians represented 20 per cent of the population of the Arab world, today two per cent

    Jaivova January 26th, 2023 at 04:49 pm回复
  2. Jaivova

    yoga for high blood pressure pdf Rogge smiled awkwardly, and said to him Your Highness, what was so funny just now cialis from usa pharmacy

    Jaivova January 29th, 2023 at 07:33 pm回复
  3. Jaivova

    I ve got some bad news for you, there is no accepted SARMs dosage that is universally going to work for everyone stromectol side effects

    Jaivova January 31st, 2023 at 12:24 am回复
取消回复

说点什么?

© 2023 烈性果汁 . 京ICP备2022032198号