Introduction and installation of SWIG

SWIG

SWIG (Simplified Wrapper and Interface Generator) is a tool for packaging C and C++ code in various target languages, allowing C/C++ API to be used in other languages.

SWIG parses the header file and generates code in a way that depends on the target language. Code generation can be controlled by the developer and command line options in the SWIG interface file .

In the interface file, the developer tells SWIG what to pack and how. SWIG has its own preprocessor system and many special instructions to control how data, classes and functions are packaged in the target language. Some of these instructions are generic, and others are specific to the target language.

The central how SWIG function is type mapping. Type mapping is a rule that specifies how to marshal types between C code and the target language. Font mapping can be applied globally to all content in the interface file, or locally based on specific conditions. They can also be customized if necessary.

Once SWIG runs on the interface file, it generates a C or C++ file, which is the wrapper. This file should be compiled and linked with a C/C++ program or static library, and the wrapper is used to interact with it to generate a shared library. The library is in turn used by the target language.

installation

1. Download address: https://sourceforge.net/projects/swig/files/

2. Unzip, configure environment variable PATH, configure path as SWIG unzip directory

3. Test:
Insert picture description here

reference

https://blog.csdn.net/aganliang/article/details/91129379
http://www.tastones.com/stackoverflow/swig/getting-started-with-swig/

Guess you like

Origin blog.csdn.net/weixin_42990464/article/details/110391138