September 26, 2019
Hi,

I am trying to get started using pyd with https://github.com/Superbelko/pyd-min as an example and I am getting an error from the linker:

    minpyd ~master: building configuration "application"...
    Linking...
    /usr/bin/ld: cannot find -lpython3.7m
    collect2: error: ld returned 1 exit status
    Error: linker exited with status 1
    dmd failed with exit code 1.


I did not modify anything from that sample code. This is a proof-of-concept and then I would move to a larger D project and Python library which uses a specific conda environment.

If I take out the pyd subConfiguration from dub.json, the build succeeds but then it picks up my system-wide python 2.7.

Does anyone know how I can indicate the linker where to look for python3.7m? How can I configure pyd to use python from my conda environment? As a small note, I am quite new to D, so I may have missed something obvious.

Best regards
Cesar
September 26, 2019
On Thursday, 26 September 2019 at 13:29:09 UTC, Cesar wrote:
> Hi,
>
> I am trying to get started using pyd with https://github.com/Superbelko/pyd-min as an example and I am getting an error from the linker:
>
>     minpyd ~master: building configuration "application"...
>     Linking...
>     /usr/bin/ld: cannot find -lpython3.7m
>     collect2: error: ld returned 1 exit status
>     Error: linker exited with status 1
>     dmd failed with exit code 1.
>
>
> I did not modify anything from that sample code. This is a proof-of-concept and then I would move to a larger D project and Python library which uses a specific conda environment.
>
> If I take out the pyd subConfiguration from dub.json, the build succeeds but then it picks up my system-wide python 2.7.
>
> Does anyone know how I can indicate the linker where to look for python3.7m? How can I configure pyd to use python from my conda environment? As a small note, I am quite new to D, so I may have missed something obvious.
>
> Best regards
> Cesar

I found what was wrong. The pyd subConfiguration of python37 was looking for my system-wide python37, which I did not have. To use the conda python, I ran the script from https://github.com/ariovistus/pyd/blob/master/setup/pyd_set_env_vars.sh:

    pyd_set_env_vars.sh <my_conda_python>

And used subConfiguration "pyd": "env". When I did that, I got a runtime error about the libraries not being found, so then I added the flag LD_LIBRARY_PATH when running the executable:

    LD_LIBRARY_PATH=~/miniconda3/envs/MYENV/lib ./executable

I still need to figure out how to move this flag into dub.son but for now it is working. Hope this helps out in case someone has the same problem.

Cesar