2013-05-17 28 views
0

我在我的系統中安裝了boostpro(boost 1.47)。 (Windows 7的32位) 當我上運行的bjam命令 「C:\ Program Files文件\提升\ boost_1_47 \庫\ python的\例如」 我收到以下錯誤在Boost Python中運行bjam時出錯

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). 

這是什麼意思?我的系統中甚至沒有tools/build/v2。我怎樣才能解決這個問題?

回答

0

與bjam戰鬥,你可以測試Scons。有一天,我正在寫一個使用boost :: python的應用程序,而Scons幫助我很多。對我來說,一切都更簡單。

這裏是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)