2013-01-24 41 views
2

鏈接VS 8.0 LIB文件6.0

這是一個非常簡單的程序(一些簡單的計算,「給的東西,得到的東西),我使用Visual Studio 8.0 SP2編譯成一個lib文件。 lib文件應該被鏈接到另一個程序中,問題是另一個程序在具有Visual Studio 6.0的計算機上

當編譯程序並鏈接到lib文件(使用VS 6.0)時出現以下錯誤和警告發生:

首先一些警告:

Linking... 
myLib.lib(SeController.o) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored 
myLib.lib(SeController.o) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored 
myLib.lib(SeController.o) : warning LNK4044: unrecognized option "alternatename:[email protected][email protected]@@@[email protected]@[email protected]@[email protected]@[email protected]@@YAPBDXZ"; ignored 
myLib.lib(SeController.o) : warning LNK4078: multiple ".CRT" sections found with different attributes (40300040) 
myLib.lib(bt_errors.o) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored 
myLib.lib(bt_errors.o) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored 
myLib.lib(SCtrlImpl.o) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored 
myLib.lib(SCtrlImpl.o) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored 

....(只是這裏的一些警告。有相同類型的hunders)

然後(部分)的錯誤:

msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char 
const *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) already defined in libcpd.lib(locale0.obj) 
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: virtual __thiscall std::basic_ostream<char,struct std::char_traits<char> >::~basic_ostream<char,struct std::char_traits<char> >(void)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]Z) alread 
y defined in libcpd.lib(iostream.obj) 
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(void)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]) already defined in 
libcpd.lib(iostream.obj) 
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: virtual __thiscall std::basic_istream<char,struct std::char_traits<char> >::~basic_istream<char,struct std::char_traits<char> >(void)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]) alread 
y defined in libcpd.lib(iostream.obj) 
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall std::basic_istream<char,struct std::char_traits<char> >::basic_istream<char,struct std::char_traits<char> >(class std::basic_streambuf<char,struct std::char_traits<char> > *,bool)" (??0?$ 
[email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected][email protected]@[email protected]@@[email protected][email protected]) already defined in libcpd.lib(iostream.obj) 
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(void)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
already defined in libcpd.lib(iostream.obj) 
msvcprt.lib(MSVCP60.dll) : error LNK2005: "protected: __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::basic_streambuf<char,struct std::char_traits<char> >(void)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]) alread 
y defined in libcpd.lib(iostream.obj) 
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _vsprintf already defined in libcd.lib(vsprintf.obj) 
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _exit already defined in libcd.lib(crt0dat.obj) 
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in libcd.lib(atox.obj) 

我試圖爲VS 8.0下載Visual Studio 2005的Redistrubate包有6.0 computering,但我得到了相同的錯誤和警告。

它甚至有可能從8.0與6.0編譯器在一個lib文件鏈接?

它不是改變安裝的版本的選項。 (並且不問爲什麼有人正在使用VS 6.0 :))

回答

1

你可以對另一個C運行應用程序鏈接,即VS 6.0,但我認爲,要求在同一臺機器上安裝了兩個版本。我知道你在談論不同的機器,所以我認爲這不是一個選項。

如果你可以用一個簡單的C API創建一個動態庫,它會使事情更容易:)你可以從VS的任何版本中使用這樣的DLL

0

如果您認爲該文本(從Interoperability of Libraries Created by Different Compiler Brands報價)則沒有,你不能 -

對象文件,並用不同的編譯器生成的靜態庫,甚至使用相同的編譯器的顯著不同版本 ,經常 不能鏈接在一起。此問題不是特定於MinGW:其他編譯器的許多 是互不兼容的。如果可以的話,使用相同版本的相同編譯器構建源自 的所有內容。

DLL的略有不同。有時你可以將一個編譯器的DLL與一個編譯器連接起來,並將其編譯成一個應用程序。如果DLL是用C編寫的,即使應用程序是用C++編寫的,這也可以很好地工作 。例如,MinGW C++程序通常鏈接到隨Windows提供的C運行時庫 。使用C++編寫的DLL也可以工作,只要通過與外部「C」聲明的C接口進行通信,只要與它們通信即可。如果你不這樣做,你可能會得到鏈接器錯誤 ,因爲不同的編譯器以不同的方式修改C++名稱。