找回密码
 欢迎注册
楼主: 〇〇

[讨论] mathe能否提供更新的windows版gmp库

[复制链接]
发表于 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
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-7 10:40:36 | 显示全部楼层
61# wayne
正如他说的“you can't use the file-relater functions ” 像fprintf , fscanf ,  mpz_out_str ,.... 如果要用,可以做个替换。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-7 19:45:57 | 显示全部楼层
62# G-Spider
之前,很早很早以前,无心人说过,要让VC编译成功 GMP,需要修改GMP源码的很多地方,
我想,这就是其中之一
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-7 20:13:54 | 显示全部楼层
本帖最后由 G-Spider 于 2011-7-7 20:29 编辑

63# wayne
涉及FIFE部分,要换c运行库?  MinGW使用的是Windows中的C运行库啊,问题在哪呢。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 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.obj  libgmp.lib
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-7 21:46:34 | 显示全部楼层
65# G-Spider
我是用vs2008的IDE编译的,工程默认是有/MD选项的,
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-7 21:51:13 | 显示全部楼层
66# wayne
哈哈,我的命令行批处理运行成功了。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-7 22:04:41 | 显示全部楼层
67# 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呢? 看你了。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2011-7-8 20:56:58 | 显示全部楼层


我都不选,呵呵
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-20 06:55 , Processed in 0.044508 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表