1

我刚刚安装了MPIR库。我测试了程序可以看到空代码中的头文件如下:

#include <iostream>
#include <conio.h>
using namespace std;

#pragma warning(disable: 4800)
#include <mpirxx.h>
#pragma warning(default: 4800)

int main (int argc, char *argv[])
{   
  mpz_class aBigPO2;

  aBigPO2 = 1073741824; //2^30
  aBigPO2*=aBigPO2; //2^60
  aBigPO2*=aBigPO2; //2^120
  aBigPO2*=aBigPO2; //2^240
  aBigPO2*=aBigPO2; //2^480
  aBigPO2*=aBigPO2; //2^960
  aBigPO2*=aBigPO2; //2^1920 
 // cout << aBigPO2 << endl;

cout<<"Hello World";
getch();
}

我尝试编译和调试上面的代码,它运行良好,我可以看到 Hello World 语句。但是,当我删除cout << aBigPO2 << endl;语句中的注释时,仅在调试时出现以下错误(编译时,它不显示任何错误)

1>InitializeBuildStatus:
1>  Touching "Debug\gcdgmp.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>mpirxx.lib(osmpz.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Main.obj
1>mpirxx.lib(osdoprnti.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Main.obj
1>mpirxx.lib(osfuns.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Main.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::width(__int64)" (?width@ios_base@std@@QAE_J_J@Z) already defined in mpirxx.lib(osfuns.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE_JPBD_J@Z) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in mpirxx.lib(osfuns.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBE_JXZ) already defined in mpirxx.lib(osfuns.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in mpirxx.lib(osdoprnti.obj)
1>c:\users\myuser\documents\visual studio 2010\Projects\gcdgmp\Debug\gcdgmp.exe : fatal error LNK1169: one or more multiply defined symbols found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.14
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我应该怎么办 ?

4

2 回答 2

0

尝试为 mpir.h 添加 #include 并查看是否可以修复它。

于 2013-08-03T19:29:31.727 回答
0

在 CPP 中,字符串文字的最大长度为 16,384 (16K) 字节。您是否检查过 (2^1920 = 9.49711451 x 10577) 是否在此范围内?

于 2013-01-02T06:42:20.227 回答