[Python] Relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle' can not be...

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I want to use C++ functions in Python. Thus, I decided to try to use SWIG for that purpose. At first, I run command:

    swig -python test.i


    Then compile it with g++-6.2 as follows:

    g++-6.2 -c test.cpp test_wrap.c -fPIC -I /usr/include/python3.6m


    To this moment everything works fine, but the problem occurs at the last step when linking must be created. I run command :

    ld -shared test.o test_wrap.o -o _test.so


    As suggested in the Swig tutorial, but I receive the following error:

    test.o: In function `__static_initialization_and_destruction_0(int, int)':
    test.cpp:(.text+0x66): undefined reference to `__dso_handle'
    ld: test.o: relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle' can not be used when making a shared object
    ld: final link failed: Bad value


    Does anyone know how to fix this?

    Continue reading...

Compartilhe esta Página