SWIG:SWIG的简介、安装、使用方法之详细攻略

简介: SWIG:SWIG的简介、安装、使用方法之详细攻略


目录

SWIG的简介

SWIG的安装

SWIG的使用方法


 

 

 

 

SWIG的简介

       SWIG是一种软件开发工具,它将C和C++编写的程序与各种高级编程语言连接起来。SWIG用于不同类型的目标语言,包括常见的脚本语言,如Javascript、Perl、PHP、Python、Tcl和Ruby。支持的语言列表还包括非脚本语言,如C#,D,Go language,Java,包括Android,Lua,OCaml,Octave,Scilab和R。还支持几种解释和编译的Scheme实现(Guile,MzScheme/Racket)。

         SWIG最常用于创建高级解释或编译的编程环境、用户界面,以及作为测试和原型化C/C++软件的工具。SWIG通常用于解析C/C++接口,并生成用于上述目标语言调用C/C++代码所需的“胶粘代码”。SWIG还可以XML格式导出解析树。SWIG是自由软件,SWIG生成的代码与商业和非商业项目都兼容。

SWIG官网http://www.swig.org/

 

SWIG的安装

下载地址https://sourceforge.net/projects/swig/files/swig/swig-4.0.1/swig-4.0.1.tar.gz/download?use_mirror=nchc

注:切记,下载的时候要选择对应的系统,比如博主选择的是Win10系统对应的swigwin-4.0.1压缩包。

安装教程:

 

 

 

SWIG的使用方法

1. C:\Users>swig -help
2. Supported Target Language Options
3.      -csharp         - Generate C# wrappers
4.      -d              - Generate D wrappers
5.      -go             - Generate Go wrappers
6.      -guile          - Generate Guile wrappers
7.      -java           - Generate Java wrappers
8.      -javascript     - Generate Javascript wrappers
9.      -lua            - Generate Lua wrappers
10.      -octave         - Generate Octave wrappers
11.      -perl5          - Generate Perl 5 wrappers
12.      -php7           - Generate PHP 7 wrappers
13.      -python         - Generate Python wrappers
14.      -r              - Generate R (aka GNU S) wrappers
15.      -ruby           - Generate Ruby wrappers
16.      -scilab         - Generate Scilab wrappers
17.      -tcl8           - Generate Tcl 8 wrappers
18.      -xml            - Generate XML wrappers
19. 
20. Experimental Target Language Options
21.      -mzscheme       - Generate MzScheme/Racket wrappers
22.      -ocaml          - Generate OCaml wrappers
23. 
24. General Options
25.      -addextern      - Add extra extern declarations
26.      -c++            - Enable C++ processing
27.      -co <file>      - Check <file> out of the SWIG library
28.      -copyctor       - Automatically generate copy constructors wherever possible
29.      -cpperraswarn   - Treat the preprocessor #error statement as #warning (default)
30.      -cppext <ext>   - Change file extension of generated C++ files to <ext>
31.                        (default is cxx)
32.      -copyright      - Display copyright notices
33.      -debug-classes  - Display information about the classes found in the interface
34.      -debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages
35.      -debug-symtabs  - Display symbol tables information
36.      -debug-symbols  - Display target language symbols in the symbol tables
37.      -debug-csymbols - Display C symbols in the symbol tables
38.      -debug-lsymbols - Display target language layer symbols
39.      -debug-tags     - Display information about the tags found in the interface
40.      -debug-template - Display information for debugging templates
41.      -debug-top <n>  - Display entire parse tree at stages 1-4, <n> is a csv list of stages
42.      -debug-typedef  - Display information about the types and typedefs in the interface
43.      -debug-typemap  - Display typemap debugging information
44.      -debug-tmsearch - Display typemap search debugging information
45.      -debug-tmused   - Display typemaps used debugging information
46.      -directors      - Turn on director mode for all the classes, mainly for testing
47.      -dirprot        - Turn on wrapping of protected members for director classes (default)
48.      -D<symbol>      - Define a symbol <symbol> (for conditional compilation)
49.      -E              - Preprocess only, does not generate wrapper code
50.      -external-runtime [file] - Export the SWIG runtime stack
51.      -fakeversion <v>- Make SWIG fake the program version number to <v>
52.      -fcompact       - Compile in compact mode
53.      -features <list>- Set global features, where <list> is a comma separated list of
54.                        features, eg -features directors,autodoc=1
55.                        If no explicit value is given to the feature, a default of 1 is used
56.      -fastdispatch   - Enable fast dispatch mode to produce faster overload dispatcher code
57.      -Fmicrosoft     - Display error/warning messages in Microsoft format
58.      -Fstandard      - Display error/warning messages in commonly used format
59.      -fvirtual       - Compile in virtual elimination mode
60.      -help           - Display help
61.      -I-             - Don't search the current directory
62.      -I<dir>         - Look for SWIG files in directory <dir>
63.      -ignoremissing  - Ignore missing include files
64.      -importall      - Follow all #include statements as imports
65.      -includeall     - Follow all #include statements
66.      -l<ifile>       - Include SWIG library file <ifile>
67.      -macroerrors    - Report errors inside macros
68.      -makedefault    - Create default constructors/destructors (the default)
69.      -M              - List all dependencies
70.      -MD             - Is equivalent to `-M -MF <file>', except `-E' is not implied
71.      -MF <file>      - Generate dependencies into <file> and continue generating wrappers
72.      -MM             - List dependencies, but omit files in SWIG library
73.      -MMD            - Like `-MD', but omit files in SWIG library
74.      -module <name>  - Set module name to <name>
75.      -MP             - Generate phony targets for all dependencies
76.      -MT <target>    - Set the target of the rule emitted by dependency generation
77.      -nocontract     - Turn off contract checking
78.      -nocpperraswarn - Do not treat the preprocessor #error statement as #warning
79.      -nodefault      - Do not generate default constructors nor default destructors
80.      -nodefaultctor  - Do not generate implicit default constructors
81.      -nodefaultdtor  - Do not generate implicit default destructors
82.      -nodirprot      - Do not wrap director protected members
83.      -noexcept       - Do not wrap exception specifiers
84.      -nofastdispatch - Disable fast dispatch mode (default)
85.      -nopreprocess   - Skip the preprocessor step
86.      -notemplatereduce - Disable reduction of the typedefs in templates
87.      -O              - Enable the optimization options:
88.                         -fastdispatch -fvirtual
89.      -o <outfile>    - Set name of C/C++ output file to <outfile>
90.      -oh <headfile>  - Set name of C++ output header file for directors to <headfile>
91.      -outcurrentdir  - Set default output dir to current dir instead of input file's path
92.      -outdir <dir>   - Set language specific files output directory to <dir>
93.      -pcreversion    - Display PCRE version information
94.      -small          - Compile in virtual elimination and compact mode
95.      -swiglib        - Report location of SWIG library and exit
96.      -templatereduce - Reduce all the typedefs in templates
97.      -v              - Run in verbose mode
98.      -version        - Display SWIG version number
99.      -Wall           - Remove all warning suppression, also implies -Wextra
100.      -Wallkw         - Enable keyword warnings for all the supported languages
101.      -Werror         - Treat warnings as errors
102.      -Wextra         - Adds the following additional warnings: 202,309,403,405,512,321,322
103.      -w<list>        - Suppress/add warning messages, eg -w401,+321 - see Warnings.html
104.      -xmlout <file>  - Write XML version of the parse tree to <file> after normal processing
105. 
106. Options can also be defined using the SWIG_FEATURES environment variable, for example:
107. 
108.   $ SWIG_FEATURES="-Wall"
109.   $ export SWIG_FEATURES
110.   $ swig -python interface.i
111. 
112. is equivalent to:
113. 
114.   $ swig -Wall -python interface.i
115. 
116. Arguments may also be passed in a file, separated by whitespace. For example:
117. 
118.   $ echo "-Wall -python interface.i" > args.txt
119.   $ swig @args.txt
120. 
121. 
122. Note: 'swig -<lang> -help' displays options for a specific target language.

 


相关文章
|
缓存 Ubuntu Java
Tool之Bazel:Bazel的简介、安装、使用方法之详细攻略
Tool之Bazel:Bazel的简介、安装、使用方法之详细攻略
|
机器学习/深度学习 Python
Py之yacs:yacs的简介、安装、使用方法之详细攻略
Py之yacs:yacs的简介、安装、使用方法之详细攻略
Py之yacs:yacs的简介、安装、使用方法之详细攻略
|
XML JSON JavaScript
Py之demjson:Python库之demjson的简介、安装、使用方法详细攻略
Py之demjson:Python库之demjson的简介、安装、使用方法详细攻略
Py之demjson:Python库之demjson的简介、安装、使用方法详细攻略
|
数据采集 算法 数据可视化
Py之Optbinning:Optbinning的简介、安装、使用方法之详细攻略
Py之Optbinning:Optbinning的简介、安装、使用方法之详细攻略
Py之Optbinning:Optbinning的简介、安装、使用方法之详细攻略
|
人工智能 并行计算 API
Py之cupy:cupy的简介、安装、使用方法之详细攻略
Py之cupy:cupy的简介、安装、使用方法之详细攻略
Py之cupy:cupy的简介、安装、使用方法之详细攻略
|
Linux Python Windows
Py之terminaltables:terminaltables的简介、安装、使用方法之详细攻略
Py之terminaltables:terminaltables的简介、安装、使用方法之详细攻略
Py之terminaltables:terminaltables的简介、安装、使用方法之详细攻略
|
JavaScript 前端开发 Python
Py之easydict:easydict的简介、安装、使用方法之详细攻略
Py之easydict:easydict的简介、安装、使用方法之详细攻略
Py之easydict:easydict的简介、安装、使用方法之详细攻略
|
Unix Linux API
Py之portalocker:portalocker的简介、安装、使用方法之详细攻略
Py之portalocker:portalocker的简介、安装、使用方法之详细攻略
Py之portalocker:portalocker的简介、安装、使用方法之详细攻略
|
数据可视化 API 计算机视觉
Py之pycocotools:pycocotools库的简介、安装、使用方法之详细攻略续篇
Py之pycocotools:pycocotools库的简介、安装、使用方法之详细攻略续篇
|
编译器 C++ Python
Py之cython:python库之cython的简介、安装、使用方法之详细攻略
Py之cython:python库之cython的简介、安装、使用方法之详细攻略
Py之cython:python库之cython的简介、安装、使用方法之详细攻略