惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
博客园_首页
罗磊的独立博客
云风的 BLOG
云风的 BLOG
J
Java Code Geeks
Last Week in AI
Last Week in AI
D
DataBreaches.Net
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
D
Docker
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
H
Help Net Security
T
The Blog of Author Tim Ferriss

博客园 - bitwoods

Linux驱动开发:内核模块堆叠(1) Linux驱动开发:内核模块与普通应用的区别 Linux驱动开发:从一个最简单的模块开始 c++ prepareStatement使用like查询语句的方式 阿里云Ubuntu服务器优化 linux c++程序使用MD5 串口AT与数据的混杂接收处理 蓝牙Mesh简介(一)设备标识:UUID和Mesh地址 MT7621 openWrt插件操作GPIO(mmap) adblock plus 您的地区不可用 OpenWRT 修改固件默认显示中文 OpenWRT:插件自启动 OpenWRT编译时修改时区与主机名 SC200L Android10启动和关机修改 ILI9881D驱动 ubuntu20.04 微信和迅雷安装包 开启power management功能有坑,ESP32串口频繁出现UART_BREAK中断 MAC地址与字符串的相互转化 ESP32音频开发板ESP32-Korvo V1.1踩坑
glog编译报错解决
bitwoods · 2024-06-06 · via 博客园 - bitwoods

编译报错

centos9上编译glog0.3.4和0.3.5报错:

src/googletest.h:579:33: error: ISO C++17 does not allow dynamic exception specifications
  579 | void* operator new(size_t size) throw(std::bad_alloc) {
      |                                 ^~~~~
src/googletest.h:586:35: error: ISO C++17 does not allow dynamic exception specifications
  586 | void* operator new[](size_t size) throw(std::bad_alloc) {
      |                                   ^~~~~
src/logging_unittest.cc: In function ‘void TestDCHECK()’:
src/logging_unittest.cc:567:3: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
  567 |   auto_ptr<int64> sptr(new int64);
      |   ^~~~~~~~
In file included from /usr/include/c++/11/bits/locale_conv.h:41,
                 from /usr/include/c++/11/locale:43,
                 from /usr/include/c++/11/iomanip:43,
                 from src/logging_unittest.cc:44:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
make: *** [Makefile:1275: src/logging_unittest-logging_unittest.o] Error 1

解决方法:

void* operator new(size_t size) throw(std::bad_alloc) {

改为

void* operator new(size_t size) {

即可;
或者根据最新的版本,将报错部分的2个函数修改为:

void* operator new(size_t size, const std::nothrow_t&) noexcept {
  if (google::g_new_hook) {
    google::g_new_hook();
  }
  return malloc(size);
}

void* operator new(size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC {
  void* p = ::operator new(size, std::nothrow);
  if (p == nullptr) {
    throw std::bad_alloc{};
  }
  return p;
}

void* operator new[](size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC {
  return ::operator new(size);
}

安装后使用报错

error while loading shared libraries: libglog.so.0: cannot open shared object file: No such file or ...

根据实际安装位置运行命令

sudo ldconfig /usr/local/lib