为什么Visual Studio 2010寻找__thiscall而不是__cdecl调用约定
Why is visual studio 2010 looking for __thiscall rather than __cdecl calling conventions?
总的来说,我正在尝试将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,因此构建标志似乎是正确的,但显然我错过了什么?
您确定使用了 x64 库吗?
Microsoft减少了 x64 中的调用约定。看这里。基本上现在一切都__fastcall
.
编译器仍然可以使用 __thiscall
,但会被忽略(MSDN 链接)。所以你的测试程序很好,但你的库看起来有问题。
__thiscall
是 VS 中对类的成员函数的默认调用约定。 也许头文件缺少__cdecl
说明符,或者编译标志设置不正确,因此没有设置相关的 #define。
__thiscall
是 MSVC 中类成员函数的默认值,您要么需要使用相同的设置编译 OpenCV,要么在标头定义中显式使用 __cdecl
。
相关文章:
- "std::unique_XXX"命名约定背后的基本原理是什么?
- 为什么在 x64 中忽略__stdcall调用约定?
- 引发异常的方法的命名约定 (C++)?
- MINGW - 正确运行函数所需的 cdecl
- 窗口调用约定
- 我应该提到纯虚函数中的调用约定吗?
- C++:在进行切片时对迭代器的约定,特别是对于访问最后一个元素并最终将其删除
- 如何使用gcc指定stdcall调用约定
- Clang:x86 FPU调用约定
- 该标准是否说明了例外和不同调用约定的共存
- Clang++的InterlockedExchange的32位调用约定错误,但MSVC可以
- std::sort & comp - 调用约定?
- C++命名空间约定
- C++的新手试图弄清楚类约定
- 如何为类 /块 /范围选择C 调用约定
- 使用char**的Pinvoke cdecl约定
- 默认情况下,是使用cdecl+fastcall约定编译的c++成员函数
- 如果存在,则使用它/检测C++中当前作用域的调用约定(thiscall vs cdecl)
- CDECL 调用约定 引起奇怪的警告 组装 X86
- AccessViolationException 当 PInvoking C++ DLL (cdecl 调用约定问题?)