Unable to compile my C Extension on Windows: unresolved external link errors

Marco Sulla Marco.Sulla.Python at gmail.com
Fri Nov 12 17:50:31 EST 2021


On Fri, 12 Nov 2021 at 21:09, Chris Angelico <rosuav at gmail.com> wrote:
>
> On Sat, Nov 13, 2021 at 7:01 AM Marco Sulla
> <Marco.Sulla.Python at gmail.com> wrote:
> > On Fri, 12 Nov 2021 at 17:38, Chris Angelico <rosuav at gmail.com> wrote:
> > > Are you sure that you really need Py_BUILD_CORE?
> >
> > Yes, because I need the internal functions of `dict`. So I need to
> > compile also dictobject.c and include it. So I need that flag.
> >
> > This is the code:
> >
> > https://github.com/Marco-Sulla/python-frozendict.git
> >
>
> Ah, gotcha.
>
> Unfortunately that does mean you're delving deep into internals, and a
> lot of stuff that isn't designed for extensions to use. So my best
> recommendation is: dig even deeper into internals, and duplicate how
> the core is doing things (maybe including another header or
> something). It may be that, by declaring Py_BUILD_CORE, you're getting
> a macro version of that instead of the normal exported function.

I've not understood what I have to do in practice.... but anyway, as I
said, Py_BUILD_CORE works on Linux and MacOS. And it works also on
Windows. Indeed dictobject.c is compiled. The only problem is in the
linking phase, when the two objects should be linked in one library,
_the_ library. It seems that on Windows it doesn't find python3.lib,
even if I put it in the path. So I get the `unresolved external link`
errors.


More information about the Python-list mailing list