Gmp 显然无法在 MinGW 下工作

发布于 2024-12-01 23:52:53 字数 731 浏览 6 评论 0原文

我整个下午都在与 GMP 和 Mingw 作斗争,经过大量尝试后我才安装它。实际上,我所做的是:安装全新的MinGW副本(32位,标准最新版本,从sourceforge下载),在安装过程中选择msys组件,然后使用msys从源安装GMP。 1)我从gmplib官网主页下载了源码(只是标准源码发布,链接在主页上部)。 2)我将其提取到msys可访问的某个位置。 3)我做了“./configure”步骤 4)然后是“make”步骤 5)然后“进行安装” 6)然后“检查”。 没问题,看起来它正在工作。我尝试在 gcc 下编译它:

#include <stdio.h>
#include <gmp.h>

int main(int argc, char *argv[])
{
  mpz_t a, b;                       /* working numbers */
  return 0;
}

它编译没有任何错误。但是,当我尝试

mpz_init(a); 

在 a 的声明下添加: 时,gcc 打印出:

C:\Users\MATTEO~1\AppData\Local\Temp\cc6wXtx9.o:gmptest.c:(.text+0x1c):取消定义 d 对 `__gmpz_init' 的引用 collect2: ld 返回 1 退出状态

您知道有关此错误的任何信息吗?有人可以帮助我吗?非常感谢!

马泰奥

I struggled during the whole afternoon with GMP and Mingw, and after a HUGE number of tries I made to install it. Actually, what I did is: installing a fresh brand new copy of MinGW (32 bit, standard latest version, downloaded from sourceforge), selecting the msys component during installation, and then using msys to install GMP from sources.
1) I downloaded sources from the home page of the gmplib official website (just the standard source release, link in the upper part of the home page).
2) I extracted it into some location reachable from msys.
3) I did the "./configure" step
4) Then the "make" step
5) Then "make install"
6) Then "make check".
No problems, it looked like it was just working. I tried to compile this under gcc:

#include <stdio.h>
#include <gmp.h>

int main(int argc, char *argv[])
{
  mpz_t a, b;                       /* working numbers */
  return 0;
}

It compiled without any error. But then, when I try to add:

mpz_init(a); 

right under the declaration of a, gcc prints out:

C:\Users\MATTEO~1\AppData\Local\Temp\cc6wXtx9.o:gmptest.c:(.text+0x1c): undefine
d reference to `__gmpz_init'
collect2: ld returned 1 exit status

Do you know anything about this error? Can anybody help me? Thank you very much!

Matteo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你另情深 2024-12-08 23:52:53

只是猜测,但是您是否包含“-lgmp”来告诉编译器链接到 gmp 库?

Just a guess, but did you include "-lgmp" to tell the compiler to link to the gmp library?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文