有人可以告诉我我是否做错了什么。建筑/包括VS2013中的Boost.Python
我在使用Visual Studio 2013的Windows 7上,我希望能够设置一个简单的Boost.Python项目。我不知道我是否犯了错误建设提升或当包括在我的项目提振。
错误
当我尝试#include
任何升压Python模块,例如#include <boost/python/module.hpp>
我在Visual Studio中出现以下错误。
1>c:\boost_1_55_0\boost\python\detail\wrap_python.hpp(50): fatal error C1083: Cannot open include file: 'pyconfig.h': No such file or directory
大厦
我试图按照从this SO thread in which KTC addresses Python指示,并this Python howto from Boost,但由于这两个链接都有点过时,都做不同的事情,一些步骤似乎在新版本中已经改变的Boost,我不得不根据一些指示即兴发挥。
这就是我所做的。
- 将Boost源文件的最新版本(1.55)解压缩到
C:\boost_1_55_0
。 - 使用
cmd.exe
导航到C:\boost_1_55_0
。 (我没有使用Developer Command Prompt for VS2013
\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
下找到。这是不应该有任何区别,应该吗?Boosts official guide for 1.55没有做出使用Command Prompt for VS2013
的任何具体提及。 - 在cmd中使用
bootstrap
。 - 编辑
project-config.jam
(由bootstrap
创建),并添加路径我的Python 3.4安装C:\Python34
。我.jam
文件现在看起来像在项目 - config.jam中看到。 - 用于CMD
.\b2
开始构建过程。虽然我在有很多的警告建成(forcing value to bool 'true' or 'false' (performance warning)
等),它的确如此内置完成后似乎没有任何错误消息。
包括
这是我建立了我的项目在Visual Studio中。
- 创建一个新项目。
- 在中添加的代码测试代码。
- 在VC++目录中的项目属性:
- 新增
C:\boost_1_55_0
到Include Directories
。 - 添加了
C:\boost_1_55_0\stage\lib
(我能找到.lib
文件的文件夹)到Library Directories
。
- 新增
项目 - config.jam中
import option ;
using msvc ;
option.set keep-going : false ;
using python : 3.4 : C:\\Python34\\python ;
测试代码
来源:boost_1_55_0\libs\python\example\getting_started1.cpp
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <string>
namespace
{
// A couple of simple C++ functions that we want to expose to Python.
std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }
}
namespace python = boost::python;
BOOST_PYTHON_MODULE(getting_started1)
{
// Add regular functions to the module.
python::def("greet", greet);
python::def("square", square);
}
我有这个的蟒蛇,注意多include目录:'使用python :3.5 :d:\\ \\温度蟒蛇\\ \\ PCbuild#python.exe CMD-或前缀 :d:\ \ temp \\ python \\ include D:\\ temp \\ cpythonorig \\ PC :D:\\ temp \\ python \\ PCbuild;' – stijn
'using python:3.4:C:\\ Python34 \\ python; ' - 不是拖尾的'\\ python'多余的? –
@UlrichEckhardt你这么认为?我不知道。我只是从[KTC的帖子中复制它]复制它(http://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-studio-2010/2655683#2655683)。但是我会很高兴能够帮助我发现错误。我的项目似乎正在工作,但我有一个警告,我无法摆脱,'1> c:\ python \ python34 \ include \ pymath.h(22):warning C4273:'round':inconsistent DLL连接“,所以也许我仍然做错了什么。 – Adelost