Skip to content

ImportError undefined symbol _ZTIPi on import clr #939

Closed

Description

@jj-tetraquark

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.

Activity

  1. jj-tetraquark commented on Aug 13, 2019

    @jj-tetraquark
    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

  2. antivirtel commented on Nov 15, 2019

    @antivirtel

    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:
    

    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?

  3. filmor commented on Nov 15, 2019

    @filmor
    Member

    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.

  4. antivirtel commented on Nov 15, 2019

    @antivirtel

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

  5. pinned this issue on Dec 3, 2019
  6. bneumann commented on Jan 28, 2020

    @bneumann

    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.

  7. lostmsu commented on Apr 22, 2020

    @lostmsu
    Member

    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.

  8. lostmsu commented on Apr 22, 2020

    @lostmsu
    Member

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

  9. filmor commented on Apr 22, 2020

    @filmor
    Member

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

  10. filmor commented on Apr 23, 2020

    @filmor
    Member

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

  11. unpinned this issue on May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions