开发者

Mono DLL to open appropriate Windows/Mac DLL/DyLib

I'm using Mono to write a wrapper over a set of natively exposed commands.

The set is the same (comm开发者_如何转开发ands and signature), however it is exposed through a DLL in Windows and a DyLib in Mac.

I was wondering if there was a way for me to create only one wrapper .NET/Mono DLL while having it still find the right library from which to import by itself.

If so, what would be the syntax? If not, what would be the compiler definitions that would separate the DllImport from 2 different OS on which I'd compile?

EDIT: Bonus points for a static lib (.a) instead of a dynamic lib (.dylib) for the Mac part, if that is even possible with Mono.


You will probably want to ship a dll map config file that tells Mono which library to load on each platform:

http://www.mono-project.com/Config_DllMap


If you can give same names to both libraries, there would be no code changes required at all. At least it worked like that for me in Windows/Linux with native library written in C.


I would use

#define MAC/WINDOWS

and

#if

inside your code. You use then -define WINDOWS or -define MAC when compiling so that the DLLs are called. So at least you will have one code base, alternatively you need to check for the environment, but this can get tricky easily.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜