WSL-Ubuntu 22.04 中编译某大型开源项目,用到 cmake,过程中报错 /usr/bin/ld: cannot find -lstdc++: No such file or directory 但实际上系统中有这个库文件,使用 ldconfig -p | grep libstdc++ 命令输出为

libstdc++.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libstdc++.so.6

libstdc++.so.6 (libc6) => /lib32/libstdc++.so.6

搜半天,有的说安装 build-essential 等等,检查已经安装了还是不行,最后找到 Intel 的一个客户支持记录 ,里面有一层回复提到

This error could arise when you have multiple gcc packages installed in your system and the compiler is unable to locate the correct system libraries. In one of the cases, I have gcc-11 and g++ -11 installed in my system, I did not face any issues while building. Thereafter, I have installed gcc-12 in my system, then the same error was reproduced while building with cmake. This issue was resolved after installing g++ -12 in my system. You can install g++ -12 by running the following commands in the terminal.

居然是因为系统里装了多个 gcc 版本,检查了下还真是,和回复提到的报错时环境情况一样,同时装了 gcc-11 和 gcc-12,但 g++ 只装了 11(不知道怎么搞的,好像都是 ubuntu 22.04 自带的?) 按回复里说的,sudo apt install g++-12 装上就好了……

相关阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: