Gmp 显然无法在 MinGW 下工作
我整个下午都在与 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是猜测,但是您是否包含“-lgmp”来告诉编译器链接到 gmp 库?
Just a guess, but did you include "-lgmp" to tell the compiler to link to the gmp library?