Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ImportError undefined symbol _ZTIPi on import clr #939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jj-tetraquark opened this issue Aug 13, 2019 · 9 comments · Fixed by #1139
Closed

ImportError undefined symbol _ZTIPi on import clr #939

jj-tetraquark opened this issue Aug 13, 2019 · 9 comments · Fixed by #1139

Comments

@jj-tetraquark
Copy link

Environment

  • Pythonnet version: v2.4.0
  • 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:

    import clr

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.

@jj-tetraquark
Copy link
Author

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
Copy link

antivirtel commented Nov 15, 2019

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: [email protected]
License: MIT
Location: /usr/lib64/python2.7/site-packages
Requires:
Required-by:

Tried with older version as well, didn't work:

# rpm -qa | grep mono
mono-mvc-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-extras-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-devel-5.18.1.3-0.xamarin.1.epel7.x86_64
libmono-llvm0-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-winforms-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-data-5.18.1.3-0.xamarin.1.epel7.x86_64
libmonosgen-2_0-1-6.4.0.198-0.xamarin.3.epel7.x86_64
mono-data-sqlite-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-wcf-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-core-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-winfxcore-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-data-oracle-5.18.1.3-0.xamarin.1.epel7.x86_64
mono-llvm-tools-6.0+mono20190708165219-0.xamarin.1.epel7.x86_64
mono-web-5.18.1.3-0.xamarin.1.epel7.x86_64

How can I make it work?

@filmor
Copy link
Member

filmor commented Nov 15, 2019

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.

@antivirtel
Copy link

Thanks @filmor, I didn't notice that package had higher version, now it works, thanks.

@filmor filmor pinned this issue Dec 3, 2019
@bneumann
Copy link

bneumann commented 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
Copy link
Member

lostmsu commented 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++ to setup.py like this:

...
libs = mono_libs.strip() + " " + glib_libs.strip() + " -lstdc++"
...

I'll wait for Mono response to give us a supported way to do this.

@lostmsu
Copy link
Member

lostmsu commented Apr 22, 2020

Aaaand after getting pythonnet successfully install with this workaround I hit #1034

@filmor
Copy link
Member

filmor commented Apr 22, 2020

The C++ linker does a bit more than just -lstdc++, it's probably enough to just use language="c++" in the Extension constructor.

@filmor
Copy link
Member

filmor commented Apr 23, 2020

And the module functions need to be extern "C".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants