相关疑难解决方法(0)

导入Cython模块的未定义符号错误

我想将我的一个c ++类作为Python模块提供.该类在头文件中声明,Foo.h并以.cpp实现Foo.cpp.(g ++ - 4.5,Ubuntu x86_64).这是一个非常简单的课程:

Foo.cpp:

Foo::Foo() : alfa(1.0), beta(1)
{

}

Foo::~Foo()
{
}
Run Code Online (Sandbox Code Playgroud)

Foo.h:

 class Foo
 {
 public:

  Foo()
  Foo(const Foo& orig);
  ~Foo();
  double alfa;
  int beta; 
 };
Run Code Online (Sandbox Code Playgroud)

我创建了一个setup.py如Cython教程中所示:

setup.py

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
  name = 'MyDemo',
  ext_modules=[
    Extension("Foo"
          sources=["Foo.pyx"], 
          include_dirs=[".","../eigen/"],
          language="c++"),
    ],
  cmdclass = {'build_ext': build_ext},
)
Run Code Online (Sandbox Code Playgroud)

并按照cython教程的指示编写我的Foo.pyxcython模块:

Foo.pyx

cdef extern from "Foo.h":
    ctypedef struct c_Foo "Foo": …
Run Code Online (Sandbox Code Playgroud)

python distutils cython undefined-reference

9
推荐指数
1
解决办法
5677
查看次数

可以用icc编译cython吗?

我正在尝试使用icc编译器在Ubuntu 14.04上从源代码构建cython,因为我的python是用Intel icc编译器编译的.

当我尝试使用pip3安装cython安装cython然后运行cython时出现以下错误

Traceback (most recent call last):
File "/usr/local/bin/cython", line 9, in <module>
load_entry_point('Cython==0.24', 'console_scripts', 'cython')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.4/dist-packages/Cython/Compiler/Main.py", line 28, in <module>
from .Scanning import PyrexScanner, FileSourceDescriptor
ImportError: /usr/local/lib/python3.4/dist-packages/Cython/Compiler/Scanning.cpython-34m.so: undefined symbol: __intel_sse2_strchr 
Run Code Online (Sandbox Code Playgroud)

如何使用icc编译器从源代码安装cython?

我试过这个并没有用

从cython目录(从github下载)

python3.4 setup.py CC = icc

我收到以下消息 -

/home/aa/libPython/cython/Cython/Distutils/build_ext.py:20: UserWarning:    
Cython.Distutils.build_ext does not properly …
Run Code Online (Sandbox Code Playgroud)

distutils cython icc python-3.x ubuntu-14.04

5
推荐指数
1
解决办法
1251
查看次数