1.linux
进入源码目录
cd glog
mkdir builder
cd builder
cmake .. -DBUILD_SHARED_LIBS=ON
make -j 8
make install
2.windows
同理修改CMakeList.txt
使用cmake生成解决方案
编译即可
测试例子
#include <glog/logging.h>
#pragma comment(lib, "glog.lib")
using namespace std;
int main(int argc, char* argv[])
{
string logpath = "./";
//init
google::InitGoogleLogging(argv[0]);
string info_log = logpath + "info_";
google::SetLogDestination(google::INFO, info_log.c_str());
string warning_log = logpath + "warning_";
google::SetLogDestination(google::WARNING, warning_log.c_str());
LOG(INFO) << "Hello Glog";
LOG(WARNING) << "Hello Glog";
getchar();
return 0;
}