C++ 笔记

Summary: Author: 张亚飞 | 阅读时间: 2 minute read | Published: 2016-06-23
Filed under Categories: C++Tags: C++, Glog, RapidJson,


C++ 虚函数的作用是什么?


vector


Glog 日志组建

git clone https://github.com/google/glog.git
cd glog
./configure
make
sudo make install
  • make 出现如下错误
一 8月 29 20:53:22 coam@coam:/opt/data/glog$ make
CDPATH="${ZSH_VERSION+.}:" && cd . && aclocal-1.14 -I m4
/bin/bash: aclocal-1.14: command not found
Makefile:957: recipe for target 'aclocal.m4' failed
make: *** [aclocal.m4] Error 127
  • 检测发现以下程序都已安装
automake --version
m4 --version
perl --version
autoconf --version

执行 autoreconf

一 8月 29 20:55:10 coam@coam:/opt/data/glog$ autoreconf
parallel-tests: error: required file './test-driver' not found
parallel-tests:   'automake --add-missing' can install 'test-driver'
autoreconf: automake failed with exit status: 1
一 8月 29 20:56:17 coam@coam:/opt/data/glog$ automake --add-missing
parallel-tests: installing './test-driver'
一 8月 29 20:56:38 coam@coam:/opt/data/glog$ autoreconf
一 8月 29 20:56:46 coam@coam:/opt/data/glog$ make
rc/demangle.h:80:27: error: expected initializer before 'Demangle'
 bool GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, int out_size);
                           ^
Makefile:1208: recipe for target 'src/libglog_la-demangle.lo' failed
make: *** [src/libglog_la-demangle.lo] Error 1

最后的完整的安装步骤如下

cd /opt/data
git clone https://github.com/google/glog.git
cd glog
mkdir build && cd build
export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1
make
sudo make install
  • 安装日志为:
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libglog.a
-- Installing: /usr/local/include/glog/config.h
-- Installing: /usr/local/include/glog/logging.h
-- Installing: /usr/local/include/glog/raw_logging.h
-- Installing: /usr/local/include/glog/stl_logging.h
-- Installing: /usr/local/include/glog/vlog_is_on.h
-- Installing: /usr/local/include/glog/log_severity.h
-- Installing: /usr/local/lib/cmake/glog/glog-config.cmake
-- Installing: /usr/local/lib/cmake/glog/glog-config-version.cmake
-- Installing: /usr/local/lib/cmake/glog/glog-targets.cmake
-- Installing: /usr/local/lib/cmake/glog/glog-targets-noconfig.cmake
#include <glog/logging.h>

int main(int argc,char* argv[])
{
    LOG(INFO) << "Hello,GLOG!";
}
  • 编译
g++ -lglog demo.cpp /usr/local/lib/libglog.a -o demo
# 或者 (注意顺序)
g++ demo.cpp -lglog -o demo
g++ -o demo demo.cpp -lglog

参考 glog 安装配置


RapidJson


Comments

Cor-Ethan, the beverage → www.iirii.com