You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ImportError undefined symbol _ZTIPi on import clr #939
Python version: 3.7.4 but it affects all versions of python I try building the library for
Operating System: Ubuntu 16.04
pythonnet installed inside a virtualenv
Details
Importing the clr library results in an import error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: /usr/lib/libmonosgen-2.0.so.1 undefined symbol: _ZTIPi
Minimal example:
importclr
This had been working just fine, however it looks like libmonosgen-2.0.so.1 updated on the 9th and I think that's what is the cause of this issue. Rebuilding completely from scratch in a fresh virtualenv doesn't fix this problem.
It doesn't work for me with older versions of mono:
# rpm -qa | grep mono
mono-extras-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-devel-5.20.1.19-0.xamarin.3.epel7.x86_64
libmono-llvm0-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-web-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-winforms-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-data-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-core-5.20.1.19-0.xamarin.3.epel7.x86_64
libmonosgen-2_0-1-6.4.0.198-0.xamarin.3.epel7.x86_64
mono-winfxcore-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-wcf-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-data-oracle-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-llvm-tools-6.0+mono20190708165219-0.xamarin.1.epel7.x86_64
mono-mvc-5.20.1.19-0.xamarin.3.epel7.x86_64
mono-data-sqlite-5.20.1.19-0.xamarin.3.epel7.x86_64
# python -c 'import clr'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: /lib64/libmonosgen-2.0.so.1: undefined symbol: _ZTIPi
# uname -a
Linux pp-mag604.uk8.scp.bskyb.com 3.10.0-1062.4.1.el7.x86_64 #1 SMP Fri Oct 18 17:15:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
# python -V
Python 2.7.5
# pip show pythonnet
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Name: pythonnet
Version: 2.4.0
Summary: .Net and Mono integration for Python
Home-page: https://pythonnet.github.io/
Author: The Python for .Net developers
Author-email: pythondotnet@python.org
License: MIT
Location: /usr/lib64/python2.7/site-packages
Requires:
Required-by:
libmonosgen-2_0-1-6.4.0.198-0.xamarin.3.epel7.x86_64 is the problem, this will not work (if you don't compile things yourself). I don't know why different C++ ABIs are used here but I also have no capacities to debug this.
Is that still an issue? I just ran into this using pythonnet 2.4 with a dotnetcore2.0 build and having latest mono-devel installed which is, at time of writing, 6.8.0.
Reacted by Mikhail Stolyarov, Mark Adamson, Andrew D. McGuire and ChristophII
I think I figured out the root cause, but don't know yet what is the proper way to fix it: mono/mono#19628
TL;DR; properly linking libmono from Mono 6.8 requires C++ linker or to manually specify C++ stdlib to be linked with C linker (e.g. -lstdc++). I believe workaround is to manually add -lstdc++ to setup.py like this:
Activity
jj-tetraquark commentedon Aug 13, 2019
Looks like this is the same issue as is being discussed here #925 (comment)
Temporary workaround is to revert and pin mono to 5.20.1
antivirtel commentedon Nov 15, 2019
It doesn't work for me with older versions of mono:
Tried with older version as well, didn't work:
How can I make it work?
filmor commentedon Nov 15, 2019
libmonosgen-2_0-1-6.4.0.198-0.xamarin.3.epel7.x86_64is the problem, this will not work (if you don't compile things yourself). I don't know why different C++ ABIs are used here but I also have no capacities to debug this.antivirtel commentedon Nov 15, 2019
Thanks @filmor, I didn't notice that package had higher version, now it works, thanks.
bneumann commentedon Jan 28, 2020
Is that still an issue? I just ran into this using pythonnet 2.4 with a dotnetcore2.0 build and having latest mono-devel installed which is, at time of writing, 6.8.0.
lostmsu commentedon Apr 22, 2020
I think I figured out the root cause, but don't know yet what is the proper way to fix it: mono/mono#19628
TL;DR; properly linking libmono from Mono 6.8 requires C++ linker or to manually specify C++ stdlib to be linked with C linker (e.g.
-lstdc++). I believe workaround is to manually add-lstdc++tosetup.pylike this:I'll wait for Mono response to give us a supported way to do this.
lostmsu commentedon Apr 22, 2020
Aaaand after getting pythonnet successfully install with this workaround I hit #1034
filmor commentedon Apr 22, 2020
The C++ linker does a bit more than just
-lstdc++, it's probably enough to just uselanguage="c++"in theExtensionconstructor.filmor commentedon Apr 23, 2020
And the module functions need to be
extern "C".