c++ - 为什么我的 setup.py 脚本会出现此错误?

标签 c++ python wrapper setup.py

所以我有一个 C++ 类,我为它制作了 python 包装器,我制作了一个 setup.py 文件来编译它以便在 python 中使用它。当我尝试运行 python setup.py install 时出现以下错误:

lipo: can't create output file: build/temp.macosx-10.5-fat3-2.7/../tools/transport-stream/TransportStreamPacket_py.o (No such file or directory)
error: command 'gcc-4.0' failed with exit status 1

我不认为问题出在正在编译的文件上,我想我一定是设置了 setup.py 错误。这是我的 setup.py 文件的样子:

from distutils.core import setup, Extension

module1 = Extension('CL_TransportStreamPacket_py',
                sources = ['../tools/transport-stream/TransportStreamPacket_py.cpp'],

                include_dirs = ['.',
                    '../common',
                    '../tools/transport-stream'],

                library_dirs = ['common',
                    '../tools/transport-stream'],

                libraries = ['Common',
                    'TransportStream']

            )

setup (name = 'CL_TransportStreamPacket_py',
     version = '1.0',
     description = 'This is the transport stream packet parser',
     ext_modules = [module1])

最佳答案

您的问题是源定义中的前导 '..'。 Distutils 使用源文件的名称来生成临时文件和输出文件的名称,但不会对其进行规范化。重新组织您的源代码树(或移动 setup.py 文件),这样您就不需要引用 '../tools/...'

关于c++ - 为什么我的 setup.py 脚本会出现此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3313625/

相关文章:

java - 将包装器数组转换为基元数组

c++ - std::vector 的 posix_memalign

c++ - 在类构造函数中为元素构造函数设置不同值的 std::vector

python - 词嵌入的 TensorFlow 双向 LSTM 编码

python - 如何有效地使用 CountVectorizer 获取目录中所有文件的 ngram 计数?

C++ 在结构/类包装器中重载自动运算符

在 Linux 机器中使用套接字发送和接收文件时出现 C++ 问题

c++ - 这个指针的内存地址是多少?

python - Django 信号 : using update_field as condition

css - 如何减少主页画廊上方和下方的空白?