On 2/21/23 20:21, Alexandros wrote:
On 21/2/23 20:41, IOhannes m zmölnig wrote:
Am 21. Februar 2023 08:41:48 MEZ schrieb Alexandros adrcki@gmail.com:
ldflags= $(shell python-config --ldflags) libs= $(shell python-config --libs)
[...]
In the pyo~.c file there's a
#include "Python.h"
. Does this mean that I should direct the Makefile to find this file? Because no Python.h file comes with the source code.Hopefully so. python.h is a file provided by python, and it is paramount that you build against the header file that matches your python installation. So you must install the python development files (python3-dev, or somesuch).
I'm not up-to-date when it comes to python C-development, but I
'python-config' smells like a deprecated tool.Initially that was python3-config, but in my system,
python
is Python3, so I thought I change it topython-config
. Is this still a deprecated tool?
it creates ad-hoc tools with non-normalized interfaces. typically, a preferred way is to use pkg-config or similar tools (that provide a standard way to query compiler/linker flags to build things). this is a general observation, but of course the Python folks can still ship (and prefer) their own tool (hence my "I'm not up-to-date when it comes to python C-development")
you should not arbitrarily change that just becaues you happen to have a 'python-config' script lying somewhere on your disk. (afaict, this script can be installed on Debian via the 'python-dev-is-python3' convenience package. i would *not* recommend relying on this, and use canonical names instead (but again, "I'm not up-to-date when it comes to python C-development" so i might be wrong about what the canonical name is).
it turns out that 'pkg-config --cflags python3' resp 'pkg-config --libs python3' should do the trick as well.
in any case, your real problem is, that your library does not link against the python dynamic library (e.g. libpython3.11). i don't know why "python3-config --libs" does not report the apropriate linker flags ("I'm not up-to-date when it comes to python C-development"), but "python3-config --embed --libs" (and you probably should add the '--embed' flag to all invocations of python3-config), as well as "pkg-config --libs python3-embed".
finally: there's an issuetracker for pyo on https://github.com/belangeo/pyo/issues which might be a better place to ask such specific questions.
mfg IOhannes