désinstallation et installation de glog

référence

Désinstaller le tutoriel d'
installation de gflags

Désinstaller glog

Utilisez la commande Locate pour obtenir le chemin d'accès approprié

~$ 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

Supprimer les fichiers d'en-tête et les fichiers de bibliothèque

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

Installer glog

Désinstallez d'abord gflags

locate gflags|grep /usr

Trouvez l'emplacement approprié
pour le désinstaller, similaire à la méthode de désinstallation de Glog

Installer glog

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

Installer gflags [En fait, vous pouvez aussi être mal à l'aise, ne l'installez pas si vous n'avez pas à le faire ...]

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

Succès du test

Code de test

//#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;
}

Si vous supprimez le commentaire, vous pouvez le tester avec gflags

Commande de test

g++ test.cc -lglog -o test
# 删掉注释连同gflagss一起测试
g++ test.cc -lglog -lgflags -lpthread -o test
A publié 177 articles originaux · J'aime 28 · Visites 50 000+

Je suppose que tu aimes

Origine blog.csdn.net/Hesy_H/article/details/105647783
conseillé
Classement