CPython: Dynamic module does not define module export function error

后端 未结 1 1812
死守一世寂寞
死守一世寂寞 2021-01-26 22:06

I just compiled my Python wrapper for C++ classes successfully. However, I am getting following messages when I am trying to load my module to the Python (through import c

相关标签:
1条回答
  • 2021-01-26 23:08

    You should not call your extension/module cell.pyx, call it differently - for example cycell.pyx.

    Why? The following steps are taken while extension is built

    1. Cython generates file cell.cpp out of cell.pyx.
    2. Compiler compiles cell.cpp to the object file cell.o.
    3. Compiler compiles cell.cc to the object file cell.o and overwrites the object file created from cell.pyx.
    4. Linker links both cell.o files (but it is in reality only one) - in the result there is nothing what was defined in cell.pyx/cell.cpp in particular PyInit_cell.

    By renaming the Cython-file you avoid that the object-file is overwritten.

    Clearly, another option would be to rename your c++-file.

    0 讨论(0)
提交回复
热议问题