编译:libm.so.6:添加符号时出错:DSO丢失,已包含-lm

问题描述 投票:0回答:1

我尝试编译一个库,它在集群上运行良好。但是,当我尝试在我的私人笔记本电脑上本地编译它时,出现以下错误:

/usr/bin/ld: CMakeFiles/zfs.dir/zfsstrctrdblck3d.cpp.o: undefined reference to symbol 'tanhl@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing

所以,我尝试的是谷歌(显然),我发现在使用 gcc 或 mpicc 编译时必须包含

-lm
标志。我尝试了标志的几个位置,但没有一个可以修复错误。还有什么可能导致此错误?

我的mpicc版本是:

gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

提前致谢,

最大

c++ compiler-errors compilation mpi
1个回答
0
投票

我遇到了这个问题,结果使用了不匹配的 C 和 C++ 编译器版本。

问题,不同版本,从Make文件打印

CC:        cc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
CXX:       gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0

通过在 make 文件前面设置以下环境变量来纠正此问题

export CC=gcc-12
export CXX=g++-12

或者正确的 CLang 编译器(如果您正在使用它)

export CC=clang-14
export CXX=clang++-14

这是由于我的电脑中随着时间的推移收集了不同版本的 GCC

alex@pop-os:/ssd/llama.cpp$ dpkg --list | grep compiler
ii  clang                                            1:14.0-55~exp2                                                  amd64        C, C++ and Objective-C compiler (LLVM based), clang binary
ii  clang-14                                         1:14.0.0-1ubuntu1                                               amd64        C, C++ and Objective-C compiler
ii  g++                                              4:11.2.0-1ubuntu1                                               amd64        GNU C++ compiler
ii  g++-11                                           11.3.0-1ubuntu1~22.04.1                                         amd64        GNU C++ compiler
ii  g++-12                                           12.1.0-2ubuntu1~22.04                                           amd64        GNU C++ compiler
ii  g++-9                                            9.5.0-1ubuntu1~22.04                                            amd64        GNU C++ compiler
ii  gcc                                              4:11.2.0-1ubuntu1                                               amd64        GNU C compiler
ii  gcc-11                                           11.3.0-1ubuntu1~22.04.1                                         amd64        GNU C compiler
ii  gcc-12                                           12.1.0-2ubuntu1~22.04  

我也安装了

sudo apt-get install libc6-dev
© www.soinside.com 2019 - 2024. All rights reserved.