使用VS 6.0链接VS 8.0 lib文件

时间:2013-01-24 12:18:07

标签: c++ visual-studio static-linking

我有一个非常简单的程序(一些简单的计算,“给出一些东西,得到一些东西),我使用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:??$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的计算机上,但我收到了相同的错误和警告。

甚至可以将8.0中的lib文件与6.0编译器链接起来吗?

不能更改已安装的版本。 (并且不要问为什么有人使用VS 6.0 :))

2 个答案:

答案 0 :(得分:1)

您可以将应用程序与另一个C运行时链接,即VS 6.0,但我认为这需要在同一台计算机上安装这两个版本。我知道你在谈论不同的机器,所以我认为这不是一个选择。

如果你可以使用普通的C API创建一个动态库,它会让事情变得更容易:)你可以在任何版本的VS中使用这样的DLL。

答案 1 :(得分:0)

如果你认为这段文字(引自Interoperability of Libraries Created by Different Compiler Brands)则不然,你就不能 -

  

使用不同编译器创建的对象文件和静态库,或   即使有相同编译器的显着不同版本,也经常   不能联系在一起。这个问题不是MinGW特有的:很多   其他编译器是互不兼容的。从中构建一切   如果可以,请使用相同版本的相同编译器。

     

Dll略有不同。有时你可以链接一个用它构建的DLL   一个编译器到另一个编译的应用程序。这很好用   如果DLL是用C语言编写的,即使应用程序是用C ++编写的。   例如,MinGW C ++程序通常链接到C运行时库   随Windows提供。用C ++编写的DLL也可以工作   因为你只通过声明的C接口与它们通信   外部“C”。如果不这样做,您可能会遇到链接器错误   因为不同的编译器会以不同的方式破坏C ++名称。

相关问题