【问题标题】:Why is visual studio 2010 looking for __thiscall rather than __cdecl calling conventions?为什么 Visual Studio 2010 寻找 __thiscall 而不是 __cdecl 调用约定?
【发布时间】:2012-08-13 13:57:56
【问题描述】:

总的来说,我正在尝试将 opencv 测试程序与我使用 64 位 Visual Studio 2010 Professional 编译的 opencv 库链接。一个示例错误是:

1>webcamtest.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall cv::VideoCapture::isOpened(void)const " (?isOpened@VideoCapture@cv@@UBE_NXZ)

问题是为什么__thiscall,当它链接的opencv_highui249.dll包含时

Symbol name  : ?isOpened@VideoWriter@cv@@UEBA_NXZ (public: virtual bool __cdecl cv::VideoWriter::isOpened(void)const )

__cdecl 有意义,这表明该库已正确构建。 链接测试程序时,正在搜索opencv_highui249.dll,因此构建标志似乎是正确的,但显然我遗漏了什么?

【问题讨论】:

    标签: c++ visual-studio-2010 opencv linker calling-convention


    【解决方案1】:

    您确定您使用的是 x64 库吗?
    Microsoft 减少了 x64 中的调用约定。见here。基本上现在一切都是__fastcall
    编译器仍然可以使用__thiscall,但它会被忽略(MSDN link)。所以你的测试程序很好,但你的库看起来不对。

    【讨论】:

      【解决方案2】:

      __thiscall 是 VS 中类成员函数的默认调用约定。也许头文件缺少__cdecl 说明符,或者编译标志设置不正确,因此没有设置相关的#define。

      【讨论】:

        【解决方案3】:

        __thiscall 是 MSVC 中类成员函数的默认值,您需要使用相同的设置编译 OpenCV,或者在标头定义中显式使用 __cdecl

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-04-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-05-03
          • 1970-01-01
          • 2011-06-13
          • 1970-01-01
          相关资源
          最近更新 更多