我一直都可以使用clang和clang++编译介子项目,方法是运行:
CC=clang CXX=clang++ meson setup clang-debug --buildtype=debug
我得到的输出是:
he Meson build system
Version: 1.1.0
Source dir: /home/maarten/github/psy-lib
Build dir: /home/maarten/github/psy-lib/clang-debug
Build type: native build
Project name: libpsy
Project version: 0.1
C compiler for the host machine: clang (clang 14.0.0-1ubuntu1 "Ubuntu clang version 14.0.0-1ubuntu1")
C linker for the host machine: clang ld.bfd 2.38
meson.build:1:0: ERROR: Compiler clang++ can not compile programs.
A full log can be found at /home/maarten/github/psy-lib/clang-debug/meson-logs/meson-log.txt
如果我跑:
meson setup debug --buildtype=debug
我得到了一个工作版本,它分别使用cc和c编译C和C。
meson-log中与clang(++)构建相关的部分是:
-----
Detecting compiler via: clang++ --version
compiler returned <Popen: returncode: 0 args: ['clang++', '--version']>
compiler stdout:
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
compiler stderr:
Running command: clang++ -E -dM -
-----
Detecting linker via: clang++ -Wl,--version
linker returned <Popen: returncode: 0 args: ['clang++', '-Wl,--version']>
linker stdout:
GNU ld (GNU Binutils for Ubuntu) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
linker stderr:
Sanity testing C++ compiler: clang++
Is cross compiler: False.
Sanity check compiler command line: clang++ sanitycheckcpp.cc -o sanitycheckcpp.exe -D_FILE_OFFSET_BITS=64
Sanity check compile stdout:
-----
Sanity check compile stderr:
/usr/bin/ld: cannot find -lstdc++: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----
meson.build:1:0: ERROR: Compiler clang++ can not compile programs.
我想meson试图做的是编译下面的程序:
class breakCCompiler;int main(void) { return 0; }
文件(sanitycheckcpp.cc)编译为:
clang++ sanitycheckcpp.cc -o sanitycheckcpp.exe -D_FILE_OFFSET_BITS=64
但是,它会失败,并出现以下错误:
/usr/bin/ld: cannot find -lstdc++
我不知道出了什么问题。我会很感激任何帮助!
1条答案
按热度按时间aor9mmx11#
简而言之,clang正在寻找libstd的另一个版本。对我来说,一个简短的,也许不是最佳的解决方案是安装另一个版本的libstdc++
安装gcc版本12也可能会有帮助。
我发现了一个类似的帖子/答案:“/usr/bin/ld:无法找到-lstdc++:运行flutter linux应用程序时没有这样的文件或目录
因此,如果你支持这个答案,请确保支持上面的答案,因为这个答案更有深度。