开发者

Using MinGW/GCC built DLL in a Visual Studio 2010 C++/CLI project

开发者 https://www.devze.com 2023-01-19 22:25 出处:网络
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

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消