我剛剛安裝了MPIR
庫。我測試過該程序可以看到空的代碼頭文件如下:無法調試我的c + +程序:錯誤LNK2038:檢測到不匹配
#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)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::width(__int64)" ([email protected][email protected]@@[email protected]) 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)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) 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 " ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@@[email protected]) 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 " ([email protected][email protected][email protected]@[email protected]@@[email protected]@QBEDXZ) already defined in mpirxx.lib(osfuns.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " ([email protected][email protected]@@QBEHXZ) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::width(void)const " ([email protected][email protected]@@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)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) 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 " ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@@[email protected]) already defined in mpirxx.lib(osdoprnti.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " ([email protected][email protected]@@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)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@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 ==========
我應該怎麼辦?
您已經獲得了該庫的發行版,它與您的調試和CRT設置不兼容。從源代碼構建該庫的調試版本。 –
您能否通過步驟澄清更多內容? –
@Hans Passant:我確實使用x64構建了這些庫併發布了設置。與我使用這些庫的項目一樣。我的設備使用英特爾至強處理器的Win x64。我的visual C++被下載到Program Files(x86)中。我再次構建了我的項目並得到:'LINK:致命錯誤LNK1181:無法打開輸入文件'mpir.lib''。這有什麼問題嗎?如何解決它。 –