gpt4 book ai didi

c++ - 如何解决 GMP 的 32 位和 64 位库之间的冲突?

转载 作者:太空宇宙 更新时间:2023-11-04 13:08:53 25 4
gpt4 key购买 nike

我正在尝试在 C++ 项目中使用 GNU 多精度 (GMP) 库。当我尝试编译我的代码(使用 g++ project.cpp)时,我得到以下输出:

Undefined symbols for architecture x86_64:
"___gmpz_clears", referenced from:
_main in project-d867c2.o
"___gmpz_inits", referenced from:
_main in project-d867c2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

从阅读相关问题来看,似乎 32 位和 64 位库之间存在一些冲突。不过我对此了解不多。

How can I resolve this conflict?

最佳答案

解决 32 位和 64 位兼容问题的一般方法是自己编译库的源代码。虽然我对 GMP 一无所知,但许多 C++ 库使用 CMAKE 或 Visual Studio 解决方案进行编译。

在 GMP 的网站上,我在下载部分找到了:

Instead of using a release, you may also get the latest code from the GMP repositories. This will require some more work compared to using a release.

文本“GMP 存储库”上有一个链接,最终位于此处:https://gmplib.org/devel/repo-usage.html

这些似乎是关于自己编译的说明。

在您的情况下,您似乎正在处理一个 64 位项目,而您的 GMP 发行版是 32 位的。如果您不使用额外资源,另一种解决方案是将您的项目简单地切换到 32 位项目。 警告:如果这样做,您可能会破坏代码。分配给超长数组或其他特定于操作系统的函数调用可能依赖于 64 位类型。

关于c++ - 如何解决 GMP 的 32 位和 64 位库之间的冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40836956/

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