gpt4 book ai didi

c++ - 使用 Clang 编译时,链接器无法在 64 位 Mint OS 下找到 32 位库

转载 作者:IT王子 更新时间:2023-10-29 00:57:07 26 4
gpt4 key购买 nike

我刚刚在 64 位 Mint 操作系统(版本 17)上安装了 Clang 3.5。我正在尝试以 32 位编译我的程序,但是我遇到了问题。

我的主目录中有一个名为 test.cpp 的文件,其中包含以下代码:

#include <iostream>

int main()
{
std::cout << "Hello" << std::endl;
}

然后我运行以下命令:

$ clang++ -m32 -Wl,--verbose test.cpp | grep libgcc

我得到以下输出:

$ clang++ -m32 -Wl,--verbose test.cpp | grep libgcc
/usr/bin/ld: skipping incompatible /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so succeeded
/usr/bin/ld: cannot find -lgcc_s
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.a failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../i386-linux-gnu/libgcc_s.so failed
/usr/bin/ld: skipping incompatible /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../i386-linux-gnu/libgcc_s.a failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/libgcc_s.so failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/libgcc_s.a failed
attempt to open /usr/bin/../lib/i386-linux-gnu/libgcc_s.so failed
/usr/bin/ld: cannot find -lgcc
attempt to open /usr/bin/../lib/i386-linux-gnu/libgcc_s.a failed
attempt to open /usr/bin/../lib32/libgcc_s.so failed
attempt to open /usr/bin/../lib32/libgcc_s.a failed
attempt to open /lib/i386-linux-gnu/libgcc_s.so failed
attempt to open /lib/i386-linux-gnu/libgcc_s.a failed
attempt to open /lib/../lib32/libgcc_s.so failed
attempt to open /lib/../lib32/libgcc_s.a failed
attempt to open /usr/lib/i386-linux-gnu/libgcc_s.so failed
attempt to open /usr/lib/i386-linux-gnu/libgcc_s.a failed
attempt to open /usr/lib/../lib32/libgcc_s.so failed
attempt to open /usr/lib/../lib32/libgcc_s.a failed
attempt to open /usr/lib/x86_64-linux-gnu/../../lib32/libgcc_s.so failed
attempt to open /usr/lib/x86_64-linux-gnu/../../lib32/libgcc_s.a failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libgcc_s.so failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libgcc_s.a failed
attempt to open /usr/bin/../lib/libgcc_s.so failed
attempt to open /usr/bin/../lib/libgcc_s.a failed
attempt to open /lib/libgcc_s.so failed
attempt to open /lib/libgcc_s.a failed
attempt to open /usr/lib/libgcc_s.so failed
attempt to open /usr/lib/libgcc_s.a failed
attempt to open /usr/i386-linux-gnu/lib32/libgcc_s.so failed
attempt to open /usr/i386-linux-gnu/lib32/libgcc_s.a failed
attempt to open /usr/x86_64-linux-gnu/lib32/libgcc_s.so failed
attempt to open /usr/x86_64-linux-gnu/lib32/libgcc_s.a failed
attempt to open //usr/local/lib/i386-linux-gnu/libgcc_s.so failed
attempt to open //usr/local/lib/i386-linux-gnu/libgcc_s.a failed
attempt to open //usr/local/lib32/libgcc_s.so failed
attempt to open //usr/local/lib32/libgcc_s.a failed
attempt to open //lib/i386-linux-gnu/libgcc_s.so failed
attempt to open //lib/i386-linux-gnu/libgcc_s.a failed
attempt to open //lib32/libgcc_s.so failed
attempt to open //lib32/libgcc_s.a failed
attempt to open //usr/lib/i386-linux-gnu/libgcc_s.so failed
attempt to open //usr/lib/i386-linux-gnu/libgcc_s.a failed
attempt to open //usr/lib32/libgcc_s.so failed
attempt to open //usr/lib32/libgcc_s.a failed
attempt to open //usr/local/lib/libgcc_s.so failed
attempt to open //usr/local/lib/libgcc_s.a failed
attempt to open //lib/libgcc_s.so failed
attempt to open //lib/libgcc_s.a failed
attempt to open //usr/lib/libgcc_s.so failed
attempt to open //usr/lib/libgcc_s.a failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libgcc.so failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/libgcc.a succeeded
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../i386-linux-gnu/libgcc.so failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../i386-linux-gnu/libgcc.a failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/libgcc.so failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/libgcc.a failed
attempt to open /usr/bin/../lib/i386-linux-gnu/libgcc.so failed
attempt to open /usr/bin/../lib/i386-linux-gnu/libgcc.a failed
attempt to open /usr/bin/../lib32/libgcc.so failed
attempt to open /usr/bin/../lib32/libgcc.a failed
attempt to open /lib/i386-linux-gnu/libgcc.so failed
attempt to open /lib/i386-linux-gnu/libgcc.a failed
attempt to open /lib/../lib32/libgcc.so failed
attempt to open /lib/../lib32/libgcc.a failed
attempt to open /usr/lib/i386-linux-gnu/libgcc.so failed
attempt to open /usr/lib/i386-linux-gnu/libgcc.a failed
attempt to open /usr/lib/../lib32/libgcc.so failed
attempt to open /usr/lib/../lib32/libgcc.a failed
attempt to open /usr/lib/x86_64-linux-gnu/../../lib32/libgcc.so failed
attempt to open /usr/lib/x86_64-linux-gnu/../../lib32/libgcc.a failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libgcc.so failed
attempt to open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../libgcc.a failed
attempt to open /usr/bin/../lib/libgcc.so failed
attempt to open /usr/bin/../lib/libgcc.a failed
attempt to open /lib/libgcc.so failed
attempt to open /lib/libgcc.a failed
attempt to open /usr/lib/libgcc.so failed
attempt to open /usr/lib/libgcc.a failed
attempt to open /usr/i386-linux-gnu/lib32/libgcc.so failed
attempt to open /usr/i386-linux-gnu/lib32/libgcc.a failed
attempt to open /usr/x86_64-linux-gnu/lib32/libgcc.so failed
attempt to open /usr/x86_64-linux-gnu/lib32/libgcc.a failed
attempt to open //usr/local/lib/i386-linux-gnu/libgcc.so failed
attempt to open //usr/local/lib/i386-linux-gnu/libgcc.a failed
attempt to open //usr/local/lib32/libgcc.so failed
attempt to open //usr/local/lib32/libgcc.a failed
attempt to open //lib/i386-linux-gnu/libgcc.so failed
attempt to open //lib/i386-linux-gnu/libgcc.a failed
attempt to open //lib32/libgcc.so failed
attempt to open //lib32/libgcc.a failed
attempt to open //usr/lib/i386-linux-gnu/libgcc.so failed
attempt to open //usr/lib/i386-linux-gnu/libgcc.a failed
attempt to open //usr/lib32/libgcc.so failed
attempt to open //usr/lib32/libgcc.a failed
attempt to open //usr/local/lib/libgcc.so failed
attempt to open //usr/local/lib/libgcc.a failed
attempt to open //lib/libgcc.so failed
attempt to open //lib/libgcc.a failed
attempt to open //usr/lib/libgcc.so failed
attempt to open //usr/lib/libgcc.a failed
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经尽我所能完成了所有谷歌搜索和 self 调查,我不确定为什么这个简单的例子不起作用。任何人都可以帮助找出我缺少的东西吗?

最佳答案

以下是使用 clang 进行交叉编译时需要确保的内容:

  • 您是否安装了 32 位 (x86) C++ 库? (看起来你有,但只是确定一下。)

  • 尝试使用 --sysroot=<location of your 32-bit multilibs> .这将告诉 clang 搜索 bin , lib , 和 include您告诉它的特定目录中的目录,而不是使用它的(定义不明确的)硬编码路径。

  • 尝试使用 -I-L选项可以更具体地告诉 clang 你的 include 和 lib 目录在哪里。

  • 如果以上方法均无效,最坏情况:尝试使用 -B <path>告诉 clang 具体使用哪个链接器的选项。也尝试将此与之前的选项结合使用。

参见 http://clang.llvm.org/docs/CrossCompilation.html有关更多细节(尽管此处未涵盖 -B 选项)

关于c++ - 使用 Clang 编译时,链接器无法在 64 位 Mint OS 下找到 32 位库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28031713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com