make 时遇到 /usr/bin/ld: cannot find -lstdc++

在Linux环境下编译源代码时,经常遇到'cannot find -lxxx'错误,意味着系统找不到所需的库文件。这个问题可能由三个原因引起:1) 缺少对应的lib;2) lib版本不匹配;3) symbolic link错误。解决方法包括使用包管理器(如yum或apt)安装缺失的库,确保库版本正确,以及检查和修复库的symbolic link。例如,在CentOS7上,可以运行'yum install glibc-static libstdc++-static'来安装必要的库。

在linux环境编译应用程式或lib的source code时常常会出现如下的错误讯息:
/usr/bin/ld: cannot find -lxxx

这些问题都是因为找不到相应的lib文件,其中xxx即表示函式库文件名称,如:libc.so、libltdl.so、libXtst.so。
其命名规则是:lib+库名(即xxx)+.so。

造成这种情况可能有有以下三种情形:
1、 系统没有安装相对应的lib
2、 相对应的lib版本不对
3、 lib(.so档)的symbolic link 不正确,没有连结到正确的函式库文件(.so)

 

第一种,解决方案如下:

CentOS 7:

yum install glibc-static libstdc++-static

Ubuntu 16.04:

apt install libstdc++-5-dev

 

doris编译 执行sh build.sh报错:-- Check for working CXX compiler: /bin/clang++ broken CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:59(message): The C++ compiler "/bin/clang++" is not able to compile a simple test program. It fails with the following output: Change Dir: /opt/apache-doris-2.1.11-rc01-src/thirdparty/src/protobuf -21.11/cmake/build/CMakeFiles/CMakeTmp Run Build Command(s):/bin/gmake -f Makefile cmTC_5f691/fastt åå /bin/gmake -f CMakeFiles/cmTC_5f691.dir/build.make CMakeFile s/cmTC_5f691.dir/build gmake[1]: Entering directory '/opt/apache-doris-2.1.11-rc01l-src/thirdparty/src/protobuf-21.11/cmake/build/CMakeFiles/CMakeTm Building CXX object CMakeFiles/cmTC_5f691.dir/testCXXCompiler.cxx.o /bin/clang++ -02 -1/opt/apache-doris-2.1.11-rc01-src/thirdparty/installed/include -fPIE -MD -MT CMakeFiles/cmTC_5f691.dir /testCXXCompiler .cxx.o -MF CMakeFiles/cmTTC_5f691.dir/testCXCompiler.cxx.-o CMakeriles/cmTC_5f691.dir/testCXCOmpiler.cxx.o -c /opt/apache-doris-2.1.11-rc01-src/thirdparty/sroc/protobuf-21.11/cmake/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx Linking CXX executable cmTC_5f691 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5f691.dir/link.txt_--verbose=1 /bin/clang++ -02 -I/opt/apache-doris-2.1.11-rc01-sırc/thirdparty/installed/include -L/opt/apache-doris-2.1.11-rc01-src/third party/installed/lib -static-libstdc++ -static-libgcc -W1,---undef ined=pthread_create _CMakeFiles/cmTC_5f691.dir/testCXCompiler.c xx.o -o cmTC_5f691 /bin/ld: cannot find -lstdc++ clang-12: error: linker command failed with exit code 1 (use -v to see invocation) gmake[1]: *** [CMakeFiles/cmTC_5f691.dir/build.make:100: cmTC_5f6911 Error 1 gmake[1]: Leaving directory '/opt/apache-doris-2.1.11-rc01-src/thirdparty/src/protobuf -21.11/cmake/build/CMakeFiles/CMakeTmp gmake: *** [Makefile:127: cmTC_5f691/fast] Error 2 CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:24 (project) Configuring incomplete, errors occurred! See also "/opt/apache-doris-2.1.11-rc01-src/thirdparty/src/protobuf-21.11/cmake/build/CMakeFiles/CMakeOutput.log" See also "/opt/apache-doris-2.1.11-rc01-src/thirdpaarty/src/protobuf-21.11/cmake/build/CMakeFiles/CMakkeError.log [root@master apache-doris-2.1.11-rc01-src]# [24342.495359] [TTM] Buffer eviction failed [24342.495789] qxl 0000:01.0: object_init failedd for (3149824, 0x0000001) [24342.496003] [drm:gxl alloc bo reserved [gx1]] *ERROR* failed to allocate URAM BO
最新发布
11-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值