建筑/包括提振.VS2013中的Python

Building/including Boost.Python in VS2013

本文关键字:中的 Python VS2013 包括提 建筑      更新时间:2023-10-16

谁能告诉我,如果我做错了什么。

我在Windows 7上使用Visual Studio 2013,我希望能够能够设置一个简单的Boost。Python项目。我不知道我是否做错了构建 boost或当包括 boost在我的项目。

误差

当我尝试#include任何boost python模块时,例如#include <boost/python/module.hpp>,我在Visual Studio中得到以下错误:

1>c:boost_1_55_0boostpythondetailwrap_python.hpp(50): fatal error C1083: Cannot open include file: 'pyconfig.h': No such file or directory
<<p> 建筑/strong>

我试着遵循这个SO线程的指令,其中KTC地址Python,这个Python如何从Boost,但是由于两个链接都有点过时,正在做不同的事情,并且一些步骤似乎在较新的Boost版本中发生了变化,我不得不即兴创作一些指令。

这就是我所做的。

  1. 解压最新版本(1.55)的Boost源文件到C:boost_1_55_0
  2. 使用cmd.exe导航到C:boost_1_55_0。(我没有使用Microsoft Visual Studio 12.0Common7ToolsShortcuts下的Developer Command Prompt for VS2013。这应该没什么区别,对吧?boost 1.55的官方指南没有特别提到使用Command Prompt for VS2013
  3. 使用bootstrap在cmd.
  4. 编辑project-config.jam(由bootstrap创建)并添加路径到我的Python 3.4安装C:Python34。我的.jam文件现在看起来像Project-Config.jam.
  5. 在cmd中使用.b2启动构建过程。虽然我在构建期间有很多警告(forcing value to bool 'true' or 'false' (performance warning)等),但构建完成后似乎没有任何错误消息。

这就是我在Visual Studio中创建项目的方法。

  1. 新建项目
  2. 增加了测试代码中的代码。
  3. 项目属性中的vc++目录下:
    1. 添加C:boost_1_55_0Include Directories
    2. 添加C:boost_1_55_0stagelib(我可以找到.lib文件的文件夹)到Library Directories .

Project-Config.jam

import option ; 
using msvc ; 
option.set keep-going : false ; 
using python : 3.4 : C:\Python34\python ;
<<p> 测试代码/strong>

From: boost_1_55_0libspythonexamplegetting_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和Library依赖项中添加Python34/include/Python34/libs/的路径。