views:

162

answers:

1

I have a communication library built on top of Qt and Google Protocol Buffers. It's currently being built with MinGW/GCC on Windows. My goal is to use the same library in C# on .NET, with the help of a thin wrapper on top using C++/CLI (bridging the unmanaged code with managed code).

I tried using the MinGW produced DLL directly in my C++/CLI project, but I keep getting linker errors (cant remember the error codes right now, but something about missing tokens and functions/signatures).

First question is: Should I be able to use the MinGW-produced DLL with the Visual Studio compiler/linker? Or do I need to compile the library again, using only VS compiler for all projects?

If I should be able to use the MinGW-produced DLL directly, how do I reference it in Visual Studio 2010? In project settings it seems to look for *.lib files, but I can't find any .lib files in the output of MinGW/GCC. It does produce *.a files, but it seems like Visual Studio don't handle this kind of file..

I should also mention that both Qt and protobuf are also compiled with MinGW. But I can of course recompile all the parts in VS 2010 if necessary.. Would have been nice to save the recompile time though, since our buildserver already has a working setup using MinGW.

+1  A: 

The easiest way to use it would be by recompiling it with Visual Studio. This is when I am assuming C++ types and classes used in the interface you intend to use.

In case you have a C interface to this library you could dynamically load the library via LoadLibrary and use GetProcAddress to access those functions.

However it depends completly on the way how you intend to use the library.

Vinzenz
Qt isn't a C interface... Recompiling with Visual Studio isn't just the easiest way, it's the only way. gcc doesn't use the same memory layout for C++ classes, so even if you created an import library for the mingw-gcc-built DLL, it wouldn't work.
Ben Voigt
Ok, thanks for the answers both of you.. I'll go ahead recompiling it all in VS then..
notbo
@Ben Voigt: I am aware of, that Qt has no C interface by itself. But he could have created one for the things he needs. In that case he could have used it. Even if it was created by MinGW
Vinzenz