使用某個網友的Android audio streaming with OpenSL ES and the NDK時發現它需要SWIG來輔助完成JNI的橋接,但在osx上並沒有提供該程式,接下來就是要說明如何安裝並完成它。
什麼是SWIG?
SWIG是一個能將C或者C++編寫的程序與其它各種高級語言如Perl, Python, Ruby, 和 Tcl進行聯接的開發工具。其原理是從C/C++頭文件中找到申明並利用他們生成腳本語言訪問C/C++代碼所必須的封裝代碼。SWIG具有高度可自定義的特點,它能幫助你生成適合你的應用程序的封裝包。
- 下載swig原始碼swig/download.html
- 解開swig檔案
- 執行./configure進行設定,但此時卻會發生
configure: error:
Cannot find pcre-config script from PCRE (Perl Compatible Regular Expressions)
library package. This dependency is needed for configure to complete,
Either:
- Install the PCRE developer package on your system (preferred approach).
- Download the PCRE source tarball, build and install on your system
as you would for any package built from source distribution.
- Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically
link against. Run ‘Tools/pcre-build.sh –help’ for instructions.
(quite easy and does not require privileges to install PCRE on your system)
- Use configure –without-pcre to disable regular expressions support in SWIG
(not recommended).
See `config.log’ for more details. - 下載pcre(Perl Compatible Regular Expressions)原始碼PCRE source
- 解壓pcre並行進入目錄來編譯它
./configure
make
sudo make install
- 開始編譯SWIG
./configure
make
sudo make install
- 執行swig
Must specify an input file. Use -help for available options.
-
看到此訊息就代表安裝成功!