开发者

How do they write different language wrappers for same library?

开发者 https://www.devze.com 2023-01-05 16:07 出处:网络
Generally a library will be released in a single language (for example C). If the library tuns out to be useful then many language wrappers for that library will be written. How exactly do they do it?

Generally a library will be released in a single language (for example C). If the library tuns out to be useful then many language wrappers for that library will be written. How exactly do they do it?

Kindly someone throw little light on this topic. If it is too language dependent pick language of your c开发者_StackOverflowhoice and explain it.


There are a few options that come to mind:

  • Port the original C library to the language/platform of your choice
  • Compile the C library into something (like a DLL) that can be invoked from other components
  • Put the library on the web, expose an API over HTTP and wrap that on the client

If I wanted to wrap a C library with a managed (.NET) layer, I'd compile the library into a DLL, exposing the APIs I wanted. Then, I'd use P/Invoke to call those APIs from my C# code.

0

精彩评论

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