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的使用方法
C:\Users>swig -help Supported Target Language Options-csharp - Generate C# wrappers-d - Generate D wrappers-go - Generate Go wrappers-guile - Generate Guile wrappers-java - Generate Java wrappers-javascript - Generate Javascript wrappers-lua - Generate Lua wrappers-octave - Generate Octave wrappers-perl5 - Generate Perl 5 wrappers-php7 - Generate PHP 7 wrappers-python - Generate Python wrappers-r - Generate R (aka GNU S) wrappers-ruby - Generate Ruby wrappers-scilab - Generate Scilab wrappers-tcl8 - Generate Tcl 8 wrappers-xml - Generate XML wrappersExperimental Target Language Options-mzscheme - Generate MzScheme/Racket wrappers-ocaml - Generate OCaml wrappersGeneral Options-addextern - Add extra extern declarations-c++ - Enable C++ processing-co <file> - Check <file> out of the SWIG library-copyctor - Automatically generate copy constructors wherever possible-cpperraswarn - Treat the preprocessor #error statement as #warning (default)-cppext <ext> - Change file extension of generated C++ files to <ext>(default is cxx)-copyright - Display copyright notices-debug-classes - Display information about the classes found in the interface-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages-debug-symtabs - Display symbol tables information-debug-symbols - Display target language symbols in the symbol tables-debug-csymbols - Display C symbols in the symbol tables-debug-lsymbols - Display target language layer symbols-debug-tags - Display information about the tags found in the interface-debug-template - Display information for debugging templates-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages-debug-typedef - Display information about the types and typedefs in the interface-debug-typemap - Display typemap debugging information-debug-tmsearch - Display typemap search debugging information-debug-tmused - Display typemaps used debugging information-directors - Turn on director mode for all the classes, mainly for testing-dirprot - Turn on wrapping of protected members for director classes (default)-D<symbol> - Define a symbol <symbol> (for conditional compilation)-E - Preprocess only, does not generate wrapper code-external-runtime [file] - Export the SWIG runtime stack-fakeversion <v>- Make SWIG fake the program version number to <v>-fcompact - Compile in compact mode-features <list>- Set global features, where <list> is a comma separated list offeatures, eg -features directors,autodoc=1If no explicit value is given to the feature, a default of 1 is used-fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code-Fmicrosoft - Display error/warning messages in Microsoft format-Fstandard - Display error/warning messages in commonly used format-fvirtual - Compile in virtual elimination mode-help - Display help-I- - Don't search the current directory-I<dir> - Look for SWIG files in directory <dir>-ignoremissing - Ignore missing include files-importall - Follow all #include statements as imports-includeall - Follow all #include statements-l<ifile> - Include SWIG library file <ifile>-macroerrors - Report errors inside macros-makedefault - Create default constructors/destructors (the default)-M - List all dependencies-MD - Is equivalent to `-M -MF <file>', except `-E' is not implied-MF <file> - Generate dependencies into <file> and continue generating wrappers-MM - List dependencies, but omit files in SWIG library-MMD - Like `-MD', but omit files in SWIG library-module <name> - Set module name to <name>-MP - Generate phony targets for all dependencies-MT <target> - Set the target of the rule emitted by dependency generation-nocontract - Turn off contract checking-nocpperraswarn - Do not treat the preprocessor #error statement as #warning-nodefault - Do not generate default constructors nor default destructors-nodefaultctor - Do not generate implicit default constructors-nodefaultdtor - Do not generate implicit default destructors-nodirprot - Do not wrap director protected members-noexcept - Do not wrap exception specifiers-nofastdispatch - Disable fast dispatch mode (default)-nopreprocess - Skip the preprocessor step-notemplatereduce - Disable reduction of the typedefs in templates-O - Enable the optimization options:-fastdispatch -fvirtual-o <outfile> - Set name of C/C++ output file to <outfile>-oh <headfile> - Set name of C++ output header file for directors to <headfile>-outcurrentdir - Set default output dir to current dir instead of input file's path-outdir <dir> - Set language specific files output directory to <dir>-pcreversion - Display PCRE version information-small - Compile in virtual elimination and compact mode-swiglib - Report location of SWIG library and exit-templatereduce - Reduce all the typedefs in templates-v - Run in verbose mode-version - Display SWIG version number-Wall - Remove all warning suppression, also implies -Wextra-Wallkw - Enable keyword warnings for all the supported languages-Werror - Treat warnings as errors-Wextra - Adds the following additional warnings: 202,309,403,405,512,321,322-w<list> - Suppress/add warning messages, eg -w401,+321 - see Warnings.html-xmlout <file> - Write XML version of the parse tree to <file> after normal processingOptions can also be defined using the SWIG_FEATURES environment variable, for example:$ SWIG_FEATURES="-Wall"$ export SWIG_FEATURES$ swig -python interface.iis equivalent to:$ swig -Wall -python interface.iArguments may also be passed in a file, separated by whitespace. For example:$ echo "-Wall -python interface.i" > args.txt$ swig @args.txtNote: 'swig -<lang> -help' displays options for a specific target language.?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的SWIG:SWIG的简介、安装、使用方法之详细攻略的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Py之pixellib:pixellib
- 下一篇: 成功解决Exception: Graph