wayne 发表于 2011-7-7 09:38:33

问题查出来了,早在2004年就有人提及:
http://gmplib.org/list-archives/gmp-discuss/2004-May/001171.html
Since it relate on MSVCRT (Microsoft), you can't use the file-relater functions like fprintf, mpz_out_str, ...MS FILE struct is different than Borland FILE struct.But
it's easily workedaround by using input/output to memory buffers, and doing
the IO using Borland files

G-Spider 发表于 2011-7-7 10:40:36

61# wayne
正如他说的“you can't use the file-relater functions ” 像fprintf , fscanf ,mpz_out_str ,.... 如果要用,可以做个替换。

wayne 发表于 2011-7-7 19:45:57

62# G-Spider
之前,很早很早以前,无心人说过,要让VC编译成功 GMP,需要修改GMP源码的很多地方,
我想,这就是其中之一

G-Spider 发表于 2011-7-7 20:13:54

本帖最后由 G-Spider 于 2011-7-7 20:29 编辑

63# wayne
涉及FIFE部分,要换c运行库?MinGW使用的是Windows中的C运行库啊,问题在哪呢。

G-Spider 发表于 2011-7-7 20:50:23

哈哈,总算搞明白了。gmp在mingw中使用的是msvcrt.dll, 通过powergrep定位到了一个关键信息!
在gmp.info-1中有一段说明:
MINGW uses the C runtime library 'msvcrt.dll' for I/O, so
   applications wanting to use the GMP I/O routines must be compiled
   with 'cl /MD' to do the same.If one of the other C runtime
   library choices provided by MS C is desired then the suggestion is
   to use the GMP string functions and confine I/O to the application.

所以在编译的时候加一句/MD 即可(默认使用msvcrt.dll作为运行库),上面的程序测试通过。
cl   /c/MD test.c
link /subsystem:console   test.objlibgmp.lib

wayne 发表于 2011-7-7 21:46:34

65# G-Spider
我是用vs2008的IDE编译的,工程默认是有/MD选项的,
:Q:

G-Spider 发表于 2011-7-7 21:51:13

66# wayne
哈哈,我的命令行批处理运行成功了。

wayne 发表于 2011-7-7 22:04:41

67# G-Spider
快快分享出来!!

G-Spider 发表于 2011-7-8 13:56:40

66# wayne
这是一个很杯具的兼容问题,虽然各版本中都可以使用/MD ,却有所不同:
启用 /MD 时VC6,VS2008,vs2010 分别对应msvcrt.dll、msvcr80.dll、MSVCR100.dll。

所以经常看到用vc6.0以上版本的开发软件(涉及运行库),会顺便捎上***.dll 系统库。
有篇文章涉及到这个问题,说的有点意思:
Dynamically linking with MSVCRT.DLL using Visual C++ 2005
“A question arises, what does Microsoft do? They deploy their applications to a variety of Windows environments. A look at Windbg’s dependencies showed it’s using MSVCRT.DLL rather than one of the newer CRTs. Microsoft’s new Network Monitor 3.1 also uses MSVCRT.DLL. Windows Desktop Search is also using the old, trusty CRT.

How can all these new applications be using the vintage CRT? They’re not still using the antique, unsupported Visual C++ 6.0, are they? Well, no. The answer is more complicated and can be found in the Windows Driver Kit (WDK).

所以wayne加了/MD 同样没有成功,我用vc6.0编译运行成功了。选用WDK还是VC6.0呢? 看你了。

wayne 发表于 2011-7-8 20:56:58

:dizzy:

我都不选,呵呵
页: 1 2 3 4 5 6 [7] 8
查看完整版本: mathe能否提供更新的windows版gmp库