简体   繁体   English

Visual Studio 2010和OpenCV上的本机C ++-DLL错误数据

[英]native C++-DLL wrong data on visual studio 2010 and OpenCV

If someone can help me I really appreciate it. 如果有人可以帮助我,我真的很感激。

I'll explain the situation in details. 我将详细解释这种情况。

I have a solution with two projects: 我有两个项目的解决方案:

  1. project for win32 DLL in unmanaged c++ 非托管C ++中Win32 DLL的项目
  2. console application project to test the DLL. 控制台应用程序项目以测试DLL。

project 1 which creates the dll uses OpenCV library statically linked. 创建dll的项目1使用静态链接的OpenCV库。

it contains the following class: 它包含以下类:

class  CData_1D: public cv::Mat // (dllexport/dllimport depending on the project)
{
 unsigned m_length;

 CData_1D(unsigned cn)
 {
 m_length = cn;

 Mat(1, cn, DataType<double>::type);
 }
}

in project 2 main() function: 在项目2 main()函数中:

main()
{
CData_1D TestUnit(10);  
cout << TestUnit.m_length; // 1124007936

}

it compiles and run with no exception, but the data is completely wrong while m_length should be 10, its always 1124007936 它可以毫无例外地编译运行,但是数据完全错误,而m_length应该为10,始终为1124007936

I've ommited the rest of the code for clarity purpose, let me know the details I have to give you. 为了清楚起见,我已省略了其余代码,请让我知道需要提供的详细信息。

Thank you for your help 谢谢您的帮助

"Native c++" does not exist, different compilers produce code that is not APB compatible http://en.wikipedia.org/wiki/Application_binary_interface , which means you cant link to it. “本地c ++”不存在,不同的编译器生成的代码与APB不兼容http://en.wikipedia.org/wiki/Application_binary_interface ,这意味着您无法链接到它。

This in my opinion is the main major issue with C++. 我认为这是C ++的主要主要问题。 To resolve the issue re-compile OpenCV with the same compiler. 要解决此问题,请使用相同的编译器重新编译OpenCV。

I'm not certain this is your issue but seems likely. 我不确定这不是您的问题,但似乎有可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM