jeudi 1 décembre 2016

Cython module imports suddenly result in undefined symbol errors on Ubuntu 16.04 when previously working

Cython no longer works appropriately on my version of Ubuntu, this appears to be related to me installing either Clion or Pycharm (both professional editions), as building worked fine previously. Anaconda version = 3.5.2 using python 3.5.2, The code is simple:

# setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize

source = ["cythonsrc/testing.pyx"]

extensions = [Extension("testing", source, language='c++', 
extra_compile_args=["-std=c++11", "-g"], 
extra_link_args=["-std=c++11"])]

setup(
ext_modules = cythonize(extensions)
)

#testing.pyx
#!python
#cython: language_level=3, boundscheck=false
# distutils: language=c++


def test2():
    print("HEF")

Build results

python cythonsrc/setup.py build_ext --inplace
/home/name/anaconda3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py:30: UserWarning: Cython.Distutils.old_build_ext does not properly handle dependencies and is deprecated.
  "Cython.Distutils.old_build_ext does not properly handle dependencies "
running build_ext

Module import results

>>> import testing
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/name/Documents/CythonTest/testing.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm

Not sure what would cause this issue, but google is failing me, I've seen people talk about g++ versions causing issue with this, however this doesn't appear to be my problem as no one has had this issue with the g++ version currently installed, and it wouldn't matter anyway I need the build process to be cross platform (and thus can't enforce g++ versions). Other people with similar undefined symbol errors are due to setup.py user error, however I've used this process with other projects on other systems and it worked, and now previous projects that were building fine no longer build on my system with out editing the code.

My inclination is that I must have downloaded or updated something (such as the Jetbrains products) that have caused some issue with the normal build or environment variables on my system.

Aucun commentaire:

Enregistrer un commentaire