What is the difference between python3.lib and python3x.lib In the Python installation libs folder?

1.1k views Asked by At

I've been compiling a C library, and linking in the Python3 lib files for Python bindings. I've been using the python39.lib file as the link, but I was wondering what the difference is between the 'versioned' number (e.g. python3x.lib) vs the non versioned one (python3.lib).

In answer to a question, forgot to mention that this is compiling on windows using gcc.

Thanks

1

There are 1 answers

3
yoonghm On BEST ANSWER

python3.lib only contains key library functions used by cpython program (or C extension for Python). python3x.lib (such as python38.lib, python39.lib) contains the full library functions. You should link to python3.lib so that your build configuration is not affected by minor Python version upgrade such as from 3.8 to 3.9.

The linking is very platform and compiler dependent. See code comment in the PC/pyconfig.h (See reference [3]).

Additional info

  1. PEP384 - Linkage
  2. Stackoverflow question on how MSVC linker looks for specific Python debug library
  3. PC/pyconfig.h