【问题标题】:Building libs in VS 2010 for use in VS 2005?在 VS 2010 中构建库以在 VS 2005 中使用?
【发布时间】:2011-12-09 13:55:07
【问题描述】:

我需要在 VS 2005 中使用 WebRTC。据我所知,为此我需要 VS 2005 SP1。否则会一直出现两个链接错误:

LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in SwitchingSampRate.obj
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: virtual char const * __thiscall std::exception::what(void)const" (?what@exception@std@@UBEPBDXZ) already defined in SwitchingSampRate.obj

由于某种原因,我无法安装 SP1。因此,为了避免这些错误,我尝试在 VS 2010 中构建 WebRTC 库文件,然后将它们链接到我的 VS 2005 解决方案。但是,这会带来其他类型的错误和警告(又是 2005 年):

warning LNK4229: invalid directive '/FAILIFMISMATCH:_MSC_VER=1600' encountered; ignored
error LNK2001: unresolved external symbol "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z)
unresolved external symbol "void (__cdecl* std::_Raise_handler)(class stdext::exception const &)" (?_Raise_handler@std@@3P6AXABVexception@stdext@@@ZA)

我想知道是否可以避免这些错误,以便我可以在我的 VS 2005 项目中使用 VS 2010 中生成的库。

【问题讨论】:

    标签: visual-studio-2010 visual-studio-2005 shared-libraries


    【解决方案1】:

    您不能将库链接到使用其他版本的 Visual Studio 构建的程序。

    【讨论】:

    • 真的吗? Chris Becke 对类似问题here 的回答怎么样?
    • 他说“只要库 API 只使用原始类型,并且不要尝试释放 () 传入的指针,或者将指针传递到他们期望的内部 malloc() 内存应用程序(或另一个库)到 free() 你应该没问题。”由于您使用的是第三方库,您确定您会满足该要求
    • 嗯,我明白了。原始类型=内置类型?因此,如果它是一个 C++ 库,除非它是使用 VS 2005 构建的(前提是我在 2005 年工作),否则我很可能无法使用它,因为它适用于类,并且类不是原始类型。对吗?
    • 是的,您还可以从不同的运行时间对函数签名进行修改,因为它似乎与您的错误有关。
    猜你喜欢
    • 1970-01-01
    • 2010-09-18
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    相关资源
    最近更新 更多