简体   繁体   English

在Windows上构建Boost.Python教程示例时出错

[英]Errors building Boost.Python tutorial example on Windows

I'm trying to set up Boost.Python 1.54.0 on Windows 7, python 2.7.3. 我正在尝试在Windows 7,python 2.7.3上设置Boost.Python 1.54.0。 I installed boost_1_54_0 and built it with Visual Studio 2010. I can build and run the quickstart and tutorial examples in the distribution (I had to add some MSVC lib dirs as library-path requirements in Jamroot, but that's OK). 我安装了boost_1_54_0并使用Visual Studio 2010构建了它。我可以在发行版中构建和运行快速入门和教程示例(我必须在Jamroot中添加一些MSVC lib dirs作为库路径要求,但这没关系)。 But when I copy the tutorial example to a different dir, not inside the boost dist dir, to make it more like a real project, bjam gives build errors. 但是,当我将教程示例复制到其他目录(而不是在boost dist目录中)以使其更像真实项目时,bjam会产生构建错误。 I changed the use-project boost location in Jamroot to /local/boost_1_54_0/ which is where boost wanted to install itself, and added a simple one-line boost-build.jam (based on something I found online): 我将Jamroot中的use-project boost位置更改为/ local / boost_1_54_0 /,boost希望在该位置进行自我安装,并添加了一个简单的单行boost-build.jam(基于我在网上找到的内容):

boost-build C:/local/boost_1_54_0/tools/build/v2 ;

but ultimately bjam gives me this error: 但最终bjam给了我这个错误:

% bjam
notice: no Python configured in user-config.jam
notice: will use default configuration
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:262: in find-jamfile from module project
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory '/local/boost_1_54_0'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:280: in load-jamfile from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:64: in load from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:89: in load-used-projects from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:75: in load from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:145: in project.find from module project
C:/local/boost_1_54_0/tools/build/v2\build-system.jam:535: in load from module build-system
C:\local\boost_1_54_0\tools\build\v2/kernel\modules.jam:289: in import from module modules
C:\local\boost_1_54_0\tools\build\v2/kernel/bootstrap.jam:139: in boost-build from module
C:\tmp\tutorial\boost-build.jam:1: in module scope from module

What else do I need to add, or what am I doing wrong? 我还需要添加什么,或者我做错了什么?

I ended up giving up on bjam for this, and just used SCons. 我最终为此放弃了bjam,只使用了SCons。 A simple SConstruct was enough: 一个简单的SConstruct就足够了:

# SConstruct for building boost python tutorial example

import os

boost_python_lib = 'boost_python-vc100-gd-1_54'
boost_top        = 'c:/boost'
python_top       = 'c:/python27'

env=Environment(TARGET_ARCH='x86',
                CCFLAGS=['/MDd', '/DEBUG', '/EHsc'],
                CPPPATH=[os.path.join(boost_top,'include/boost-1_54'),
                         os.path.join(python_top, 'include')],
                LIBPATH=[os.path.join(boost_top, 'lib/i386'),
                         os.path.join(python_top, 'libs')])
dll=env.SharedLibrary('hello_ext', 'hello.cpp',
                      LIBS=boost_python_lib)
env.InstallAs('hello_ext.pyd', dll[0])
# Copy the boost python lib into this dir so hello_ext will find it at runtime
env.Install('.', os.path.join(boost_top, 'lib/i386', '%s.dll'%boost_python_lib))

Of course you could make a real SCons Tool out of this, but that was enough to get me going. 当然,您可以使用此工具制作一个真正的SCons 工具 ,但这足以使我前进。 Hope it's useful to others. 希望对其他人有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM