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

推荐订阅源

SecWiki News
SecWiki News
I
InfoQ
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
博客园_首页
罗磊的独立博客
V
V2EX
李成银的技术随笔
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
True Tiger Recordings
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
F
Fox-IT International blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
M
Microsoft Research Blog - Microsoft Research
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
The Register - Security
The Register - Security
G
Google Developers Blog
The Hacker News
The Hacker News
Malwarebytes
Malwarebytes
S
Securelist
博客园 - 三生石上(FineUI控件)
Jina AI
Jina AI
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
SegmentFault 最新的问题
博客园 - 叶小钗
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
博客园 - 聂微东
T
Threatpost
博客园 - 【当耐特】
D
Docker
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
V
Visual Studio Blog
C
Cisco Blogs
IT之家
IT之家
S
Security Archives - TechRepublic
Latest news
Latest news
阮一峰的网络日志
阮一峰的网络日志

Jun's Blog

2023 年度总结 OS 学习记 之 XV6 如何编译 GraalVM LLVM 中端优化之 InstCombine C++ 中 inline 关键字的语义 链接与库 C++ 移动语义基础 如何优化矩阵相乘 2022年度总结 CUDA初学笔记 汇编语言之保护模式 汇编语言之实模式 浅析 libc++ 中的 string 实现 std::expected 基本使用 C++模板基础 CSAPP第九章笔记之虚拟内存 CSAPP第八章笔记之异常控制流 2021年度总结 如何给LLVM贡献代码 CSAPP第三章笔记Part 2 CSAPP第三章笔记Part 1 GDB基本使用笔记 读Effetive Modern C++ 之类型推导 给计算机新生的一封信 CMake学习笔记 由Redis学习数据结构--字典 C++中lambda表达式基础 由Redis学习数据结构--链表 对Python及爬虫行业的思考 Vim实用技巧 浅谈C++中的类 简要剖析const关键字 正则表达式基础总结 使用Hugo和Firebase部署个人博客 浅谈HTTPS证书 Linux下使用v2ray 娱乐至死读书笔记 自控力读书笔记 少有人走的路力读书笔记 Postfix & Dovecot 自建邮箱服务 Linux用户管理 Linux常用命令总结 Linux开机流程 Git学习笔记 Linux文件与目录 Linux硬盘管理 Linux服务浅谈 About Me
编译安装GCC12
2022-01-01 · via Jun's Blog

· Jun

因为想用C++20标准的原因,所以要求使用GCC12。可是Ubuntu20默认的编译器是GCC9,于是只好自己编译安装一个 GCC trunk。

没想到听起来很简单的事情,真正做起来竟然有那么多的坑,所以还是稍微写点文字记录一下。

下载源码

1
git clone https://github.com/gcc-mirror/gcc.git

配置依赖

1
sudo apt install flex
1
2
cd gcc
./contrib/download_prerequisites

编译

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mkdir build && cd build

../configure -v \
  --build=x86_64-linux-gnu \
  --host=x86_64-linux-gnu  \
  --target=x86_64-linux-gnu \
  --enable-checking=no      \
  --enable-languages=c,c++  \
  --disable-multilib        \
  --prefix=/usr/local       \
  --disable-bootstrap

make -j$(nproc)

耐心等待编译完成,具体时间要看机器的性能。

安装

1
sudo make install

踩的坑

安装好gcc后不知道为什么在编译LLVM的时候会报错:

1
/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found

使用strings /lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX可以发现确实没有GLIBCXX_3.4.30。 使用ls -al /lib/x86_64-linux-gnu/libstdc++.so.6可以发现这是一个软链接:

1
lrwxrwxrwx 1 root root 36 1月   1 13:44 libstdc++.so.6 -> libstdc++.so.6.29

很显然这还是旧版本的libstdc++,观察安装后gcc给我们的提示:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Libraries have been installed in:
   /usr/local/lib/../lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

更新LD_LIBRARY_PATH即可:

将下面命令加入到用户shell配置文件中:

1
export LD_LIBRARY_PATH=/usr/local/lib64