安装glog和gflags

1.下载

git clone https://github.com/google/glog

2.配置

sudo apt-get install autoconf automake libtool

3.编译&安装

进入源码根目录
./autogen.sh
./configure
make -j 24
sudo make install

4.结果

make[1]: Entering directory '/home/xxx/Downloads/glog'
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libglog.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libglog.so.0.0.0 /usr/local/lib/libglog.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libglog.so.0.0.0 libglog.so.0 || { rm -f libglog.so.0 && ln -s libglog.so.0.0.0 libglog.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libglog.so.0.0.0 libglog.so || { rm -f libglog.so && ln -s libglog.so.0.0.0 libglog.so; }; })
libtool: install: /usr/bin/install -c .libs/libglog.lai /usr/local/lib/libglog.la
libtool: install: /usr/bin/install -c .libs/libglog.a /usr/local/lib/libglog.a
libtool: install: chmod 644 /usr/local/lib/libglog.a
libtool: install: ranlib /usr/local/lib/libglog.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/share/doc/glog-0.3.5'
 /usr/bin/install -c -m 644 AUTHORS COPYING ChangeLog INSTALL NEWS README README.windows doc/designstyle.css doc/glog.html '/usr/local/share/doc/glog-0.3.5'
 /bin/mkdir -p '/usr/local/include/glog'
 /usr/bin/install -c -m 644 src/glog/log_severity.h '/usr/local/include/glog'
 /bin/mkdir -p '/usr/local/include/glog'
 /usr/bin/install -c -m 644 src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h '/usr/local/include/glog'
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libglog.pc '/usr/local/lib/pkgconfig'
make[1]: Leaving directory '/home/xxx/Downloads/glog'

5.下载gflags

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

6.编译&安装

进入源码目录
cmake .
make -j 24
sudo make install

7.简单示例

#include <glog/logging.h>  
//#include<gflags/flags.h>  
int main(int argc,char* argv[]) {  
    // 要使用下面的api,需要安装额外的gflags,以及添加上面注释的头文件   
    // google::ParseCommandLineFlags(&argc, &argv, true);  
  
    // Initialize Google's logging library.  
    google::InitGoogleLogging(argv[0]);  
  
    FLAGS_log_dir = "./log";
    //or  google::SetLogDestination(google::GLOG_INFO, "./log_");  
  
    LOG(INFO) << "hello world";  
  
    return 0;  
} 

编译时加上glog的动态库

如:g++ test.cc -lglog -lgflags -lpthread -o test

log目录要事先创建好再在程序中指定才行,亲测。

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏安富莱嵌入式技术分享

【RL-TCPnet网络教程】第9章 RL-TCPnet网络协议栈移植(uCOS-III)

本章教程为大家讲解RL-TCPnet网络协议栈的uCOS-III操作系统移植方式,学习了第6章讲解的底层驱动接口函数之后,移植就比较容易了,主要是添加库文件、配...

853
来自专栏个人分享

spark单机模式简单搭建

待安装列表 hadoop hive scala spark 一.环境变量配置: ~/.bash_profile PATH=$PATH:$HOME/bin

3091
来自专栏JavaWeb

项目中Spring 声明式事务使用的一些坑点分析01

6348
来自专栏北京马哥教育

Python大法之告别脚本小子---信息资产收集类脚本编写

在采集到URL之后,要做的就是对目标进行信息资产收集了,收集的越好,你挖到洞也就越多了............当然这一切的前提,就是要有耐心了!!!由于要写工具...

1040
来自专栏向治洪

ActivityManagerService启动过程分析

之前讲Android的View的绘制原理和流程的时候,讲到过在Android调用setContentView之后,Android调用了一个prepreTravl...

2278
来自专栏Kubernetes

containerd源码分析

本文是对containerd v0.2.4的源码分析。 ##Containerd源码流程图 ? 源码接口调用详情 从ctr调用containerd-api #...

6007
来自专栏Kubernetes

Kubernetes Nginx Ingress Controller源码分析之创建篇

main controllers/nginx/pkg/cmd/controller/main.go:29 func main() { // start a ...

6897
来自专栏乐沙弥的世界

publickey,gssapi-with-mic,Unspecified GSS failure

        最近的MHA配置时碰到了Permission denied (publickey,gssapi-with-mic,password)这个错误提示...

1072
来自专栏沃趣科技

ASM 翻译系列第四十弹:理解ASM中 REQUIRED_MIRROR_FREE_MB和USABLE_FILE_MB的含义

原作者:Harald van Breederode 译者: 魏兴华 审核: 魏兴华 DBGeeK社区联合出品 原文链接:https://prutse...

37012
来自专栏Ryan Miao

SpringCloud学习5-如何创建一个服务提供者provider

1123

扫码关注云+社区