我正在尝试将DLL(使用MSVC编译)与MinGW编译器一起使用。 dll和二进制文件都使用通过相应编译器(MSVC DLL的MSVC和MinGW二进制的MinGW)编译的opencv dll。但是,opencv vesrion是相同的2.42。

我可以成功加载DLL(使用extern C),但是从DLL调用SetRect函数会导致以下控制台输出:

Set search rect(qt): 162, 119, 50, 50
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
Set search rect(dll): 2282800, 2282908, 2282840, 1874777202
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)
(Internal error: pc 0x112 in read in psymtab, but not in symtab.)

为什么数字不同,内部错误是什么,我该如何解决?

一些代码,请注意Rect类来自Opencv。

MinGW二进制文件:
std::cout << "Rect(qt): " << rect.x << ", " << rect.y << ", " << rect.width << ", " << rect.height << "\n" << std::flush;
SetRect(rect);

MSVC DLL:
void SetRect(Rect rect)
{
    std::cout << ""Rect(dll): " << rect.x << ", " << rect.y << ", " << rect.width << ", " << rect.height << "\n" << std::flush;
}

谢谢。

最佳答案

除非您提供Short, Self Contained, Correct (Compilable), Example,否则我们将无法重现您的问题。

我建议您仔细查看MinGW FAQ,特别是MSVC and MinGW DLLs部分,因为它涵盖了what you are trying to accomplish

关于visual-c++ - 从MinGW的MSVC DLL调用函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14473329/

10-11 23:05
查看更多