如何使用distutils在64位元中制作pyd?

时间:2018-11-19 08:11:57

标签: python opencv distutils embedding

我正在尝试制作一些在python中使用opencv的程序。我必须实时地做一些工作。所以我用python做UI和其他东西,然后用C ++做核心程序。我尝试使用distutils,但这使我发疯。

import os
from distutils.core import setup, Extension
import distutils.sysconfig

# Variable Set
OPENCV_ROOT_DIR = "D:\\opencv"

# Internal variables
OPENCV_INCLUDE_DIR = OPENCV_ROOT_DIR + "\\build\\include"
OPENCV_LIBRARY_DIR = OPENCV_ROOT_DIR + "\\build\\x64\\vc15\\lib"
OPENCV_DLL_DIR = OPENCV_ROOT_DIR + "\\build\\x64\\vc15\\bin"
OPENCV_LIBRARY = "opencv_world343"

customCore = Extension("myCore", 
                        sources=[
                            os.path.dirname(os.path.realpath(__file__)) + "\\src.cpp",
                        ],
                        include_dirs=[
                            OPENCV_INCLUDE_DIR,
                        ],
                        library_dirs=[
                            OPENCV_LIBRARY_DIR,
                        ],
                        libraries=[
                            OPENCV_LIBRARY
                        ])

setup(name="myCore",
    version="1.0",
    description="My Core program",
    ext_modules=[customCore],
    data_files=[(distutils.sysconfig.get_python_lib(), [OPENCV_DLL_DIR + "\\" + OPENCV_LIBRARY + ".dll"])]
)

在我的桌面上,这个setup.py没问题。但是,我的笔记本电脑出现了链接错误

  

opencv_world343.lib(opencv_world343.dll):致命错误LNK1112:模块   机器类型“ x64”与目标机器类型“ X86”冲突

我的笔记本电脑和台式机均使用Windows 10 64bit。我不知道为什么会出错。唯一的区别是opencv版本。我的台式机使用3.4.2,笔记本电脑使用3.4.3。这种差异会造成问题吗??

0 个答案:

没有答案