glog安装编译和使用

1 篇文章 0 订阅

记录一下glog的安装编译和使用过程,为了以后方便再次配置。

一、glog

Building glog with CMake

When building glog as a standalone project, on Unix-like systems with GNU Make as build tool, the typical workflow is:

  1. Get the source code and change to it. e.g., cloning with git:
git clone https://github.com/google/glog.git
cd glog
  1. Run CMake to configure the build tree.
cmake -S . -B build -G "Unix Makefiles"

CMake provides different generators, and by default will pick the most relevant one to your environment. If you need a specific version of Visual Studio, use cmake . -G <generator-name>, and see cmake --help for the available generators. Also see -T <toolset-name>, which can be used to request the native x64 toolchain with -T host=x64.

  1. Afterwards, generated files can be used to compile the project.
cmake --build build
  1. Test the build software (optional).
cmake --build build --target test
  1. Install the built files (optional).
cmake --build build --target install

二、gflags

下载 git clone https://github.com/gflags/gflags

编译安装命令和上面glog的一样

三、使用

需要引入头文件

 #include <glog/logging.h>

 #include <iostream>
 #include <glog/logging.h>

 int main(int argc, char *argv[])
 {
     google::InitGoogleLogging(argv[0]);
     FLAGS_log_dir = "/logdir/";
     LOG(INFO) << "hello world";
     google::ShutdownGoogleLogging();

     return 0;
 }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值