Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
SWIG
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Function== [[File:Swig file interrelations.svg|400px|thumb|Files involved when Swig is used for binding C++ to Python.<ref>Adapted from Ammar Nejati, Mikhail Svechnikov, Joachim Wuttke: Deploying a C++ Software with (or without) Python Embedding and Extension. In Bernoth et al, eds: deRSE24 - Selected Contributions of the 4th Conference for Research Software Engineering in Germany. [https://eceasst.org/index.php/eceasst/article/view/2596 ECEASST 83 (2025)].</ref>]] The aim is to allow the calling of native functions (that were written in C or C++) by other programming languages, passing complex data types to those functions, keeping memory from being inappropriately freed, inheriting object classes across languages, etc. The programmer writes an interface file containing a list of C/C++ functions to be made visible to an interpreter. SWIG will compile the interface file and generate code in regular C/C++ and the target programming language. SWIG will generate [[Marshalling (computer science)|conversion code]] for functions with simple arguments; conversion code for complex types of arguments must be written by the programmer. The SWIG tool creates [[source code]] that provides the glue between C/C++ and the target language. Depending on the language, this glue comes in two forms: *a [[library (computer science)#Shared libraries|shared library]] that an extant interpreter can link to as some form of extension module, or *a shared library that can be linked to other programs compiled in the target language (for example, using [[Java Native Interface]] (JNI) in Java). *a shared [[dynamic library]] source code that should be compiled and dynamically loaded (e.g. Node.js native extensions) SWIG is not used for calling interpreted functions by native code; this must be done by the programmer manually.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)