编译boost_1_40_0步骤
at redhat el 5.4
首先是下载boost,可以在此
下载boost_1_40_0.tar.bz2完毕后,解压到/opt。
tar jzvf boost_1_40_0.tar.bz2 -C /opt
进入boost目录:
cd /opt/boost_1_40_0/
首先我们要编译bjam:
cd tools/jam
./build_dist.sh
很快编译结束,默认情况下,生成的bjam在/opt/boost_1_40_0/tools/jam/stage/boost-jam-3.1.17-1-linuxx86目录下.
将bjam拷贝到/opt/boost_1_40_0/
现在你可以使用bjam编译boost了。
./bjam install
默认用gcc编译
你所要做的就是等待了
cd /etc/ld.so.conf.d
vim boost.conf
输入:/usr/lcoal/lib
ldconfig
这样就可以动态加载了
使用该脚本可以简单的编译boost程序,放在/usr/local/bin中,即可
#!/usr/bin/python
import os
import sys
import re
#BOOST_ROOT = os.getenv('BOOST_ROOT')
#BOOST_LIB = os.getenv('BOOST_LIB')
BOOST_ROOT = '/usr/local/include'
BOOST_LIB = '/usr/local/lib'
def getlibs():
alls = os.listdir(BOOST_LIB)
# libpattern = re.compile(r'^libboost_([^-]+)-gcc')
libpattern = re.compile(r'^libboost_([^-]+).so')
libs = {}
for lib in alls:
m = libpattern.match(lib)
if m:
libs[m.group(1).lower()] = 1
return libs
pattern = re.compile(r'^\s*#include\s*<\s*boost/(.+)\.(h|hpp)\s*>')
libs = getlibs()
#print libs
libskeys = libs.keys()
#print libskeys
includes = {}
ENV = os.environ
ARGV = sys.argv[1:]
files = ARGV
if len(files) == 0:
sys.exit()
for f in files:
if f.lower().endswith('.cpp'):
fp = open(f, 'r')
lines = fp.readlines()
for ln in lines:
m = pattern.match(ln)
if m:
libname = m.group(1).lower()
if libname in libskeys:
includes[libname] = 1
libline = ' '.join(map(lambda lib: '-lboost_'+lib, includes.keys()))
obj = ARGV[0]
obj = obj[:len(obj)-4]
cmd = 'g++ %s -I%s %s -lboost_system -o %s' % (' '.join(files), BOOST_ROOT, libline, obj)
#cmd = 'g++ %s %s -o %s' % (' '.join(files), libline, obj)
print cmd
os.system(cmd)
阅读(2086) | 评论(0) | 转发(0) |