SWIG源码安装
https://github.com/swig
下载源码首先需要先生成.configure
,在执行make
& make install
./autogen.sh
+ test -d Tools/config
+ aclocal -I Tools/config
./autogen.sh: 11: aclocal: not found
报错了
解决方案,安装automake
sudo apt-get install automake libtool -y
再次执行
./autogen.sh
+ test -d Tools/config
+ aclocal -I Tools/config
+ autoheader
+ automake --add-missing --copy --force-missing
configure.ac:23: installing 'Tools/config/compile'
configure.ac:11: installing 'Tools/config/config.guess'
configure.ac:11: installing 'Tools/config/config.sub'
configure.ac:12: installing 'Tools/config/install-sh'
configure.ac:12: installing 'Tools/config/missing'
Source/Makefile.am: installing 'Tools/config/depcomp'
+ autoconf
+ cd CCache
+ autoreconf
开始编译
make
# 报错
make[1]: Entering directory '/home/bing/occ/swig/Source'
/bin/bash '/home/bing/occ/swig/Tools/config/missing' bison -d -Wall -Werror --output=CParse/parser.c ./CParse/parser.y
/home/bing/occ/swig/Tools/config/missing: line 81: bison: command not found
WARNING: 'bison' is missing on your system.You should only need it if you modified a '.y' file.You may want to install the GNU Bison package:<https://www.gnu.org/software/bison/>
make[1]: *** [Makefile:1346: CParse/parser.c] Error 127
make[1]: Leaving directory '/home/bing/occ/swig/Source'
make: *** [Makefile:36: source] Error 2
(base) bing@bing-ThinkPad-T14p-Gen-1:~/occ/
解决办法,继续安装提示缺少的库
$ sudo apt-get install bison
安装完,再次执行make
执行成功
$ make
$ sudo make install
...
Installing /usr/local/share/swig/4.3.0/std/std_wsstream.i
Installing /usr/local/share/swig/4.3.0/std/std_wstreambuf.i
Installing /usr/local/share/swig/4.3.0/std/std_wstring.i
make[1]: Entering directory '/home/bing/occ/swig/CCache'
Installing ccache-swig
Installing /usr/local/bin/ccache-swig
/usr/bin/install -c -d /usr/local/bin
/usr/bin/install -c -m 755 ccache-swig /usr/local/bin/ccache-swig
make[1]: Leaving directory '/home/bing/occ/swig/CCache'
Installation complete
安装成功
我们查看一下swig的版本
$ swig -versionSWIG Version 4.3.0Compiled with g++ [x86_64-pc-linux-gnu]Configured options: +pcrePlease see https://www.swig.org for reporting bugs and further information