How to link to python 3.6.4 library on linux ?

Chris Angelico rosuav at gmail.com
Mon Feb 19 17:04:37 EST 2018


On Tue, Feb 20, 2018 at 8:07 AM, Jason Qian via Python-list
<python-list at python.org> wrote:
>  Hi,
>
>       I am calling python from a  c application.
>       It compiles and works fine on the windows. How do I compile and link
> it on the linux for Python 3.6.4  ?
>
>       Under python dir, it only have a static library,
>
>        /opt/Python-3.6.4*/lib*/*libpython3.6m.a*
>
> *     If I link to it, I got:*
>
> */opt/Python-3.6.4/lib/libpython3.6m.a(abstract.o): relocation R_X86_64_32S
> against `_Py_NotImplementedStruct' can not be used when making a shared
> object; recompile with -fPIC*
> */opt/Python-3.6.4/lib/libpython3.6m.a: could not read symbols: Bad value*
>

By "calling Python from C", do you mean what the docs call "embedding"?

https://docs.python.org/3/extending/embedding.html

I would recommend following the tutorial there, if you haven't
already. If you have, and the tutorial code doesn't work for you, post
your code and what you did, and we'll try to help with that.

ChrisA



More information about the Python-list mailing list