Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do they write different language wrappers for same library?

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 choice and explain it.

like image 230
claws Avatar asked Jun 29 '10 18:06

claws


People also ask

What is a language wrapper?

Wrappers can be individual software components, independent software products, software architectures, classes in object-oriented programming, or frameworks. If you want to use functions or code blocks of another programming language within a program, you can encapsulate them using a wrapper.

Is Python a wrapper language?

Python [Graduated]This it currently the most popular wrapper (followed by the Java Wrapper), and it is currently used across a large number of use-cases, serving custom logic with models trained using Keras, PyTorch, StatsModels, XGBoost, scikit-learn and even custom operating system based proprietary engines.

What is a library wrapper Python?

Wrapper libraries (or library wrappers) consist of a thin layer of code (a "shim") which translates a library's existing interface into a compatible interface. This is done for several reasons: To refine a poorly designed or complicated interface.

What is wrapper library in c++?

A wrapper consists of three separate code libraries; these are the top-level library and the fenced and unfenced libraries. The shared library for the top-level library is provided as part of the wrapper development kit. The remaining two libraries must be built from your wrapper code.


1 Answers

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.

like image 145
Jim Lamb Avatar answered Sep 29 '22 19:09

Jim Lamb