在Boost Python中运行bjam时出错 [英] Error while running bjam in Boost Python

查看:295
本文介绍了在Boost Python中运行bjam时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的系统中安装了boostpro(boost 1.47)。 (Windows 7 32位)
当我在C:\Program Files\boost\boost_1_47\libs\python\example上运行bjam命令时出现以下错误

  C:\Program Files\boost\boost_1_47\libs\python\example\boost-build.jam attempts 
通过调用

加载构建系统boost-build ../../../tools/build/v2;'

但是我们无法在指定的目录
或BOOST_BUILD_PATH中查找bootstrap.jam(搜索C:\Program Files\boost\boost_1_47\libs\python\
example\ ../。 ./../tools/build/v2)。

这是什么意思?我甚至没有在我的系统中的tools / build / v2。

解决方案

不用与bjam打交道,你可以测试 Scons 。有一天我在写一个使用boost :: python的应用程序,Scons帮助了我很多。对我来说,一切都简单得多。



这里是Sconstruct的例子:

 code> import os,shutil,platform,re 
import SCons.Builder

def copyLibBuilder(target,source,env):
'''copy library' '
shutil.copy(str(source [0]),str(target [0]))
return

env = Environment()
$ b b env.Append(ENV = {'PATH':os.environ ['PATH']})

if(platform.system()==Linux):

env.Append(CPPPATH = ['/usr/include/python2.7'])
env.Append(LIBPATH = ['/usr/lib/python2.7'])

env.Append(CPPFLAGS ='-Wall -pedantic -pthread -O3 -std = c ++ 0x -lboostpython')
env.Append(LINKFLAGS ='-Wall -pthread')

env.Append(LIBS = ['boost_python'])

elif(platform.system()==Windows):
env.Append(CPPPATH = [Dir 'C:/ Boost / include / boost-1_52'),#路径安装的boost头
Dir('C:/ Python27 / include')])#路径安装python headers
env.Append (LIBPATH = [Dir('C:/ Boost / lib'),#path to boost library
Dir('C:/ Python27 / libs')])#path to python

env.Append(CPPFLAGS ='/ EHsc / MD / DWIN32/ D_CONSOLE/ W4')
env.Append(LINKFLAGS ='/ SUBSYSTEM:WINDOWS')

else:
print platform.system()+不支持

#build C ++库
cpplib = env.SharedLibrary(target ='sources',
source = ['file1.cpp','file2.cpp'])
if(platform.system()==Linux):
target ='my_new_module.so'
elif platform.system()==Windows):
target ='my_new_module.pyd'
env.Command(target,cpplib,copyLibBuilder)
pre>

I have installed boostpro (boost 1.47) in my system. (Windows 7 32-bit) when I run bjam command on "C:\Program Files\boost\boost_1_47\libs\python\example" I get the following error

C:\Program Files\boost\boost_1_47\libs\python\example\boost-build.jam attempted
to load the build system by invoking

   'boost-build ../../../tools/build/v2 ;'

but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching C:\Program Files\boost\boost_1_47\libs\python\
example\../../../tools/build/v2).

What does this mean? I don't even have tools/build/v2 in my system. How can I fix this?

解决方案

Instead of fighting with bjam, you could test Scons. One day I was writing an application which was using boost::python and Scons helped me a lot. For me everything was much more simpler.

And here is an example of Sconstruct:

import os, shutil, platform, re
import SCons.Builder

def copyLibBuilder( target, source, env):
   '''copy library'''
   shutil.copy( str(source[0]), str(target[0]) )
   return

env = Environment()

env.Append( ENV = {'PATH' : os.environ['PATH'] })

if(platform.system() == "Linux"):

   env.Append( CPPPATH = ['/usr/include/python2.7'] )
   env.Append( LIBPATH = ['/usr/lib/python2.7'] )

   env.Append( CPPFLAGS = '-Wall -pedantic -pthread -O3 -std=c++0x -lboostpython' )
   env.Append( LINKFLAGS = '-Wall -pthread' )

   env.Append( LIBS = [ 'boost_python' ] )

elif(platform.system() == "Windows"):
   env.Append( CPPPATH = [ Dir('C:/Boost/include/boost-1_52'), # path to installed boost headers 
                           Dir('C:/Python27/include') ] ) # path to installed python headers
   env.Append( LIBPATH = [ Dir('C:/Boost/lib'), # path to boost library
                           Dir('C:/Python27/libs') ] ) #path to python

   env.Append( CPPFLAGS = ' /EHsc /MD /D "WIN32" /D "_CONSOLE" /W4' )
   env.Append( LINKFLAGS = ' /SUBSYSTEM:WINDOWS ' )

else:
   print platform.system() + " not supported"

#build C++ library
cpplib = env.SharedLibrary( target = 'sources', 
                source = ['file1.cpp', 'file2.cpp'])
if(platform.system() == "Linux"):
   target = 'my_new_module.so'
elif(platform.system() == "Windows"):
   target = 'my_new_module.pyd'
env.Command(target, cpplib, copyLibBuilder )

这篇关于在Boost Python中运行bjam时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆