因此,我尝试创建一个脚本,用于在 Linux 上使用具有Zlib支持的Iostream自动编译Boost 。目前我有这个:
#!/bin/bash
BOOST_DISTRO_SITE=surfnet.dl.sourceforge.net
BOOST_PROJECT_URL=project/boost/boost
BOOST_NAME=boost_1_48_0
BOOST_VERSION=1.48.0
BOOST_DISTRO_NAME="$BOOST_NAME".tar.gz
BOOST_ROOT_DIR=boost_libraries
BOOST_INSTALL_SUBDIR=install-dir
BOOST_COMPILE_SUBDIR=build-dir
ZLIB_NAME=zlib-1.2.5
ZLIB_PROJECT_URL=project/libpng/zlib
ZLIB_VERSION=1.2.5
ZLIB_DISTRO_NAME="$ZLIB_NAME".tar.gz
ZLIB_ROOT_DIR=zlib_libraries
ZLIB_INSTALL_SUBDIR=install-dir
ZLIB_COMPILE_SUBDIR=build-dir
KEEP_OLD="true"
echo API: boost_net_setup.sh BOOST_ROOT_DIR BOOST_INSTALL_SUBDIR KEEP_OLD BOOST_VERSION BOOST_NAME BOOST_DISTRO_SITE
if [ "$1" != "" ]; then
BOOST_ROOT_DIR="$1"
fi
if [ "$2" != "" ]; then
BOOST_INSTALL_SUBDIR="$2"
fi
if [ "$3" != "" ]; then
KEEP_OLD="$3"
fi
if [ "$4" != "" ]; then
BOOST_VERSION="$4"
fi
if [ "$5" != "" ]; then
BOOST_NAME="$5"
fi
if [ "$6" != "" ]; then
BOOST_DISTRO_SITE="$6"
fi
#-L protects against redirects
CURL_CMD=curl\ -L
# Run a command, and echo before doing so. Also checks the exit
# status and quits if there was an error.
#
# WARNING : Does *not* work when the command uses the redirection operator (>)
#
echo_run ()
{
echo "$@"
"$@"
r=$?
if test $r -ne 0 ; then
exit $r
fi
}
extract() # 1=DISTRO_NAME 2=ROOT_DIR 3=NAME
{
echo_run tar -xzf $1
echo_run rm -rf $2
echo_run mv $3 $2
}
load() # 1=DISTRO_NAME 2=ROOT_DIR 3=NAME 4=VERSION 5=BOOST_DISTRO_SITE 6=INSTALL_SUBDIR 7=PROJECT_URL
{
if [ ! -e $1 ]; then
# get boost
echo_run ${CURL_CMD} http://$5/$7/$4/$1 -o $1
fi
if [ ! -d $2 ]; then
echo_run mkdir $2
fi
# move the boost distro into place
if [ ! -d $2/$6/lib ]; then
extract $1 $2 $3
else
if [ ! KEEP_OLD=="true" ]; then
extract $1 $2 $3
fi
fi
}
WD=`pwd`
MACHINE=`uname`
HERE=`dirname $0`
cd $HERE
load $ZLIB_DISTRO_NAME $ZLIB_ROOT_DIR $ZLIB_NAME $ZLIB_VERSION $BOOST_DISTRO_SITE $ZLIB_INSTALL_SUBDIR $ZLIB_PROJECT_URL
cd $ZLIB_ROOT_DIR
if [ ! -d $ZLIB_INSTALL_SUBDIR/lib ]; then
./configure --static --prefix=./"$ZLIB_INSTALL_SUBDIR"
make
make install
fi
cd ../
load $BOOST_DISTRO_NAME $BOOST_ROOT_DIR $BOOST_NAME $BOOST_VERSION $BOOST_DISTRO_SITE $BOOST_INSTALL_SUBDIR $BOOST_PROJECT_URL
cd $BOOST_ROOT_DIR
echo_run ./bootstrap.sh
echo_run ./b2 -j4 -d0 --with-thread --with-system --with-filesystem --with-program_options --with-regex --with-date_time --with-iostreams -sZLIB_INCLUDE="$WD"/"$ZLIB_ROOT_DIR"/ -sZLIB_BINARY="$WD"/"$ZLIB_ROOT_DIR"/"$ZLIB_INSTALL_SUBDIR"/lib -sNO_BZIP2=1 link=static runtime-link=static --prefix=./$BOOST_INSTALL_SUBDIR release --builddir=./$BOOST_COMPILE_SUBDIR install
echo Done!
exit 0;
但是一旦我的脚本开始运行 boost build 命令,我就会得到:
./b2 -j4 -d0 --with-thread --with-system --with-filesystem --with-program_options --with-regex --with-date_time --with-iostreams -sZLIB_INCLUDE=/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/zlib_libraries/ -sZLIB_BINARY=/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/zlib_libraries/install-dir/lib -sNO_BZIP2=1 link=static runtime-link=static --prefix=./install-dir release --builddir=./build-dir install
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/kernel/class.jam:88: in new
*** argument error
* rule object(searched-lib-target)@1055.__init__ ( name : project : shared ? : search * : action )
* called with: ( /home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/zlib_libraries/install-dir/lib : object(project-target)@294 : : : object(null-action)@1054 : : : : )
* extra argument стол/mask-viewer-standalone/MaskLoader/zlib_libraries/install-dir/lib
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/tools/builtin.jam:406:see definition of rule '__init__' being called
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/tools/builtin.jam:574: in searched-lib-generator.run
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/tools/unix.jam:113: in object(unix-searched-lib-generator)@28.run
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1004: in try-one-generator-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1066: in try-one-generator
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1282: in construct-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1366: in generators.construct
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/tools/builtin.jam:477: in object(lib-generator)@5.run
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1004: in try-one-generator-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1066: in try-one-generator
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1282: in construct-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/generators.jam:1366: in generators.construct
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1495: in construct
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1297: in object(typed-target)@299.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:732: in generate-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:704: in object(main-target)@1040.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:258: in object(project-target)@294.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:848: in targets.generate-from-reference
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1217: in generate-dependencies
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1268: in object(install-target-class)@114.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:732: in generate-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:704: in object(main-target)@874.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:848: in targets.generate-from-reference
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1217: in generate-dependencies
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1268: in object(alias-target-class)@108.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:732: in generate-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:704: in object(main-target)@873.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:848: in targets.generate-from-reference
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1217: in generate-dependencies
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1268: in object(alias-target-class)@107.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:732: in generate-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:704: in object(main-target)@872.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:848: in targets.generate-from-reference
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1217: in generate-dependencies
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1268: in object(alias-target-class)@124.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:732: in generate-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:704: in object(main-target)@878.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:848: in targets.generate-from-reference
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1217: in generate-dependencies
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:1268: in alias-target-class.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/boostcpp.jam:409: in build-multiple
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/boostcpp.jam:373: in object(top-level-target)@130.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:732: in generate-really
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build/targets.jam:704: in object(main-target)@882.generate
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/build-system.jam:736: in load
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/kernel/modules.jam:283: in import
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/tools/build/v2/kernel/bootstrap.jam:142: in boost-build
/home/tim/Рабочий стол/mask-viewer-standalone/MaskLoader/boost_libraries/boost-build.jam:17: in module scope
tim@tim-desktop:~/Рабочий стол/mask-viewer-standalone/MaskLoader$
您几乎可以在任何 linux 上测试此脚本,它会给出相同的结果。我在 Ubuntu 10.04 LTS(最新的 Boost 1.48)上测试过
任何帮助或想法如何解决此类问题?