Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ boost python无法创建扩展dll_C++_Python_Boost_Dll - Fatal编程技术网

C++ boost python无法创建扩展dll

C++ boost python无法创建扩展dll,c++,python,boost,dll,C++,Python,Boost,Dll,我正在尝试编译boost文件。发生的情况是,运行bjam时,我将在bin/msvc-11.0/debug目录中创建以下文件: hello.obj,hello.obj.rsp,hello_ext.exp,hello_ext.lib,hello_ext.pdb,hello_ext.pyd,hello_ext.pdb.manifest,hello_ext.pyd.rsp。 但是没有创建dll。如果我运行hello.py,我会得到: 导入错误:DLL加载失败。找不到特定模块 为什么bjam不构建dll?

我正在尝试编译boost文件。发生的情况是,运行bjam时,我将在bin/msvc-11.0/debug目录中创建以下文件:

hello.obj,hello.obj.rsp,hello_ext.exp,hello_ext.lib,hello_ext.pdb,hello_ext.pyd,hello_ext.pdb.manifest,hello_ext.pyd.rsp。

但是没有创建dll。如果我运行hello.py,我会得到:

导入错误:DLL加载失败。找不到特定模块


为什么bjam不构建dll?

下面的文件是我的一个项目中的逐字记录,应该会给你一个想法。 注意,它试图找到要链接的Python的默认版本。也许有更好的方法可以做到这一点。 如果有不清楚的地方,请随时在评论中提问。 使用此SConstruct构建的boostpython模块称为
genocpp
。如果您克隆,您应该能够构建它 项目代码,假设您使用的是Linux。有了窗户,这将更加困难

作为项目代码的一部分,您还可以在上联机找到此文件

#!/usr/bin/python

import commands, glob, os

# Common file, for both executables and Python Interface
common_files = """geno print"""

def pyversion():
        pystr = commands.getoutput('python -V')
        version = pystr.split(' ')[1]
        major, minor = version.split('.')[:2]
        return major + '.' + minor

common_base = Split(common_files)
common = [f + ".cpp" for f in common_base]
common_obj = [f+".o" for f in common_base]

# For Python interface only
pif_conv = Split("cppvec_conv cppmap_conv cppset_conv cppunicode_conv")
pif_conv_files = [t+"_pif.cpp" for t in pif_conv]
pif = Split("geno")
pif_files = [t+"_pif.cpp" for t in pif]

# Boost Python Environment
boost_python_env = Environment(
    #CXX="g++-4.4",
    CPPPATH=["/usr/include/python"+pyversion(), "."],
    CXXFLAGS='-ftemplate-depth-100 -fPIC -Wall -Werror -pedantic -pipe -O3 -ffast-math -march=opteron',
    CPPDEFINES=['BOOST_PYTHON_DYNAMIC_LIB'],
    LIBPATH=["/usr/lib/python"+pyversion()+"/config"],
    LIBS=["python"+pyversion(), "m", "boost_python"],
    SHLIBPREFIX="", #gets rid of lib prefix
    SHOBJSUFFIX = ".bpo"
    )

test_env = Environment(
    #CXX="g++-4.4",
    CXXFLAGS='-Wall -Werror -pedantic -O0 -g',
    )

# Build boost python module
boost_python_env.SharedLibrary(target='genocpp', source = common + pif_conv_files + pif_files)
test_env.Program(target='geno_test', source = common + ["geno_test.cpp"])

bjam对于构建系统imo来说是一个糟糕的选择。您可以找到关于如何使用示例SCON构建boost python扩展的教程。我就是这么做的。我知道这不能回答你的问题。如果你对如何做这件事的更多细节感兴趣,请告诉我,我会补充一些东西,尽管网上有一些例子。是的,我已经找到了一些提到烤饼的文章。我会检查一下。但是如果你能在这里举个例子说明如何用它来做,我会很感激。我会看一看,尽管我在windows上。