Install google-glog 0.6.0 on Ubuntu 22.04
Download and compile and install goolge glog
$ git clone https://github.com/google/glog.git
$ sudo apt install autoconf automake libtool
$ cd glog
$ cmake -S . -B build -G "Unix Makefiles"
$ cmake --build build
$ cd build
$ make
$ sudo make install
$ sudo ldconfig
Test
#include <iostream>
#include <glog/logging.h>
int main(int argc, char **argv)
{
google::SetLogDestination(google::INFO, "/home/jimmy/glog.log");
google::InitGoogleLogging("log_test");
LOG(INFO) << "This is INFO!";
LOG(WARNING) << "This is WARNING!";
LOG(ERROR) << "This is ERROR!";
LOG(FATAL) << "This is FATAL";
return 0;
}
Compile command is as following:
$ g++ glog_test.cc -lglog
Comments
Post a Comment