在VC ++编译的应用程序中使用G ++编译的DLL(插件)时会出现什么问题? [英] What problems can appear when using G++ compiled DLL (plugin) in VC++ compiled application?

查看:137
本文介绍了在VC ++编译的应用程序中使用G ++编译的DLL(插件)时会出现什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用和应用程序与 Visual C ++ 编译器一起编译。它可以以 .dll 的形式加载插件。这是相当不重要的,事实是:

UML图>



这包括从 .dll 调用函数,它们返回一个指向应用程序 API 等。



我的问题是,应用程序从调用函数时可能出现什么问题。 dll ,从中检索指针并使用它。例如,我想到的是指针的大小。 VC ++和G ++有什么不同?如果是的话,这可能会导致应用程序崩溃?



我不想使用Visual Studio IDE(这不幸是使用Applications SDK的首选方法)。我可以将G ++配置为像VC ++一样编译吗?



PS:我使用MINGW GNU G ++

解决方案

只要应用程序和DLL都在同一台机器上编译,并且只要它们只使用C ABI,就应该没问题。
$ b

你当然不能做的是共享任何类型的C ++构造。例如,您不得在主应用程序中使用 new [] 数组,并让DLL delete [] 它。这是因为没有固定的C ++ ABI,因此任何给定的编译器都无法知道不同的编译器如何实现C ++数据结构。这对于MSVC ++的不同版本来说也是如此,它们不是ABI兼容的。


I use and Application compiled with the Visual C++ Compiler. It can load plugins in form of a .dll. It is rather unimportant what exactly it does, fact is:

This includes calling functions from the .dll that return a pointer to an object of the Applications API, etc.

My question is, what problems may appear when the Application calls a function from the .dll, retrieves a pointer from it and works with it. For example, something that comes into my mind, is the size of a pointer. Is it different in VC++ and G++? If yes, this would probably crash the Application?

I don't want to use the Visual Studio IDE (which is unfortunately the "preferred" way to use the Applications SDK). Can I configure G++ to compile like VC++?

PS: I use MINGW GNU G++

解决方案

As long as both application and DLL are compiled on the same machine, and as long as they both only use the C ABI, you should be fine.

What you can certainly not do is share any sort of C++ construct. For example, you mustn't new[] an array in the main application and let the DLL delete[] it. That's because there is no fixed C++ ABI, and thus no way in which any given compiler knows how a different compiler implements C++ data structures. This is even true for different versions of MSVC++, which are not ABI-compatible.

这篇关于在VC ++编译的应用程序中使用G ++编译的DLL(插件)时会出现什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆