安装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 条评论
登录 后参与评论

相关文章

来自专栏闻道于事

js登录滑动验证,不滑动无法登陆

js的判断这里是根据滑块的位置进行判断,应该是用一个flag判断 <%@ page language="java" contentType="text/html...

6658
来自专栏张善友的专栏

Mix 10 上的asp.net mvc 2的相关Session

Beyond File | New Company: From Cheesy Sample to Social Platform Scott Hansel...

2527
来自专栏陈仁松博客

ASP.NET Core 'Microsoft.Win32.Registry' 错误修复

今天在发布Asp.net Core应用到Azure的时候出现错误InvalidOperationException: Cannot find compilati...

4818
来自专栏我和未来有约会

Silverlight第三方控件专题

这里我收集整理了目前网上silverlight第三方控件的专题,若果有所遗漏请告知我一下。 名称 简介 截图 telerik 商 RadC...

3975
来自专栏java 成神之路

使用 NIO 实现 echo 服务器

4537
来自专栏杨龙飞前端

scrollto 到指定位置

2494
来自专栏转载gongluck的CSDN博客

cocos2dx 打灰机

#include "GamePlane.h" #include "PlaneSprite.h" #include "BulletNode.h" #include...

5346
来自专栏pangguoming

Spring Boot集成JasperReports生成PDF文档

由于工作需要,要实现后端根据模板动态填充数据生成PDF文档,通过技术选型,使用Ireport5.6来设计模板,结合JasperReports5.6工具库来调用渲...

1.2K7
来自专栏我和未来有约会

Kit 3D 更新

Kit3D is a 3D graphics engine written for Microsoft Silverlight. Kit3D was inita...

2506
来自专栏大内老A

The .NET of Tomorrow

Ed Charbeneau(http://developer.telerik.com/featured/the-net-of-tomorrow/) Exciti...

30810

扫码关注云+社区