我有一个非常简单的程序(一些简单的计算,“输入一些东西,取出一些东西),我使用 Visual Studio 8.0 SP2 编译成一个 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:??$get_name@Vinvalid_argument@std@@@Exception@Impl@Core@@YAPBDXZ=?get_name@Exception@Impl@Core@@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
....(这里只是一些警告。有数百个相同类型)
然后(一些)错误:
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 *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@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)" (??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ) 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)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) 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)" (??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ) 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?$
basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z) 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)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ)
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)" (??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ) 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 的计算机,但我得到了相同的错误和警告。
甚至可以使用 6.0 编译器从 8.0 链接到 lib 文件吗?
更改已安装版本不是一个选项。(并且不要问为什么有人使用 VS 6.0 :))