glog卸载与安装

reference

卸载教程
gflags安装

卸载glog

使用locate命令获得相关路径

~$ locate glog |grep /usr
/usr/local/include/glog
/usr/local/include/glog/config.h
/usr/local/include/glog/log_severity.h
/usr/local/include/glog/logging.h
/usr/local/include/glog/raw_logging.h
/usr/local/include/glog/stl_logging.h
/usr/local/include/glog/vlog_is_on.h
/usr/local/x86_64-linux-gnu/libglog.a
/usr/local/x86_64-linux-gnu/cmake/glog

删除头文件 & 库文件

# 删头文件
sudo rm -rf /usr/local/include/glog/
# 删库文件
sudo rm -rf /usr/local/x86_64-linux-gnu/libglog*

安装glog

先卸载gflags

locate gflags|grep /usr

查找下相关位置
类似卸载glog的方法卸载它

安装glog

git clone https://github.com/google/glog
./autogen.sh
./configure
make -j 32
sudo make install

安装gflags 【其实也可以不安 – 没有必要的话就别安装了… 】

git clone https://github.com/gflags/gflags.git
cd gflags
mkdir build && cd build
cmake .. -DGFLAGS_NAMESPACE=google -DCMAKE_CXX_FLAGS=-fPIC ..
make -j4
sudo make install

测试是否成功

测试代码

//#include <gflags/gflags.h>
#include <glog/logging.h>
#include<iostream>

//DEFINE_string(hosts, "127.0.0.1", "the server host");
//DEFINE_int32(ports, 12306, "the server port");

int main(int argc, char** argv) {
    // 解析命令行参数,一般都放在 main 函数中开始位置
    //gflags::ParseCommandLineFlags(&argc, &argv, true);
    std::string host = "127.0.0.1";
    int port =32;
    LOG(INFO)<<"nihao";
    // 访问参数变量,加上 FLAGS_
    std::cout << "The server host is: " << host
        << ", the server port is: " << port << std::endl;
    return 0;
}

把注释删掉的话就可以连同gflags一起测试

测试命令

g++ test.cc -lglog -o test
# 删掉注释连同gflagss一起测试
g++ test.cc -lglog -lgflags -lpthread -o test
发布了177 篇原创文章 · 获赞 28 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/Hesy_H/article/details/105647783