Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What problems can appear when using G++ compiled DLL (plugin) in VC++ compiled application?

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:

UML Diagram

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++

like image 812
Niklas R Avatar asked Dec 06 '22 16:12

Niklas R


1 Answers

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.

like image 182
Kerrek SB Avatar answered Apr 29 '23 21:04

Kerrek SB