[Python] Linkage error during link of C Python module

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to setup a Python module to access my C++ library. I wrote the .cpp interface and then a setup.py like this:

    setup(
    name="otawapy",
    ...
    ext_modules = [
    Extension(
    "otawapy",
    ["otawapy.cpp"],
    include_dirs=["/home/casse/Dev/local/include"],
    library_dirs=["/home/casse/Dev/local/lib "],
    libraries = ["otawa", "elm", "gel++", "gel"]
    )
    ]
    )



    Notice that all paths are exacts. When I run the installation (python3 setup.py install --user on Linux), I get (I translated some messages from french):

    ...
    x86_64-linux-gnu-g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.10/otawapy.o -L/home/casse/Dev/local/lib -lotawa -lelm -lgel++ -lgel -o build/lib.linux-x86_64-3.10/otawapy.cpython-310-x86_64-linux-gnu.so
    /usr/bin/ld : cannot find -lotawa : Aucun fichier ou dossier de ce nom
    /usr/bin/ld : cannot find -lelm : Aucun fichier ou dossier de ce nom
    /usr/bin/ld : cannot find -lgel++ : Aucun fichier ou dossier de ce nom
    /usr/bin/ld : cannot find -lgel : Aucun fichier ou dossier de ce nom
    collect2: error: ld returned 1 exit status
    error: command '/usr/bin/x86_64-linux-gnu-g++' failed with exit code 1


    Even more weird, if I copy'n'paste this command in my terminal, it works without any error. Any idea?

    Continue reading...

Compartilhe esta Página