# Libffi and ctypes.LIBFFI\_VERSION

**URL:** <https://discuss.python.org/t/libffi-and-ctypes-libffi-version/110410>\
**Category:** Ideas\
**Created:** [December 1, 2026, 10:08pm UTC](https://discuss.python.org/t/libffi-and-ctypes-libffi-version/110410 "2026-12-01T22:08:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkacvins](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@tkacvins](https://discuss.python.org/u/tkacvins)\
**Post date:** [December 1, 2026, 10:08pm UTC](https://discuss.python.org/t/libffi-and-ctypes-libffi-version/110410/1 "2026-12-01T22:08:33Z")

</div>

I had a reason to find out which underlying version of libffi was used to build the \_ctypes C module. Google’s AI overview hallucinated and said that with `Python 3.14+` and l`ibffi 3.5+`, one could run

```python
import ctypes
ctypes.LIBFFI_VERSION

```

to get the underlying version of `libffi` that was used. But this code throws an exception. I know on Linux (where I build the `libffi` version I want to use), the resulting `libffi.so.8` contains the symbols `ffi_get_version` and `ffi_get_version_number`. However, on Windows where `libffi` is an external dependency, these symbols are not exported from `libffi-8.dll`.

I happened to notice if I use `vcpkg` to build `ffi-8.dll`, these symbols are exported.

My rationale for wanting those symbols available is so that one can access them to get the version of `libffi` used to build `_ctypes`. I do not know if anyone is clamoring for this. I went to file a GitHub issue for a feature request, but I was directed to [discuss.python.org](http://discuss.python.org) to solicit feedback as to whether there was community support for it.

Circling back to `libffi-8.dll` , I see that this is built using a `Cygwin` environment which redirects to the Visual Studio tool chain. I have _zero_ clue as to whether the Python development community would want to switch to using a `vcpkg` built version of `libffi`. That adds another layer of complexity for building Python on Windows.

So, with that said, any comments about this are welcomed, even if you tell me to go pound sand.

---

<div class="post-metadata">

**Author:** ![skirpichev](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/skirpichev/32/39377_2.png) [@skirpichev](https://discuss.python.org/u/skirpichev)\
**Post date:** [December 1, 2026, 10:26pm UTC](https://discuss.python.org/t/libffi-and-ctypes-libffi-version/110410/2 "2026-12-01T22:26:19Z")

</div>

> Google’s AI overview hallucinated and said that with `Python 3.14+` and `libffi 3.5+`, one could run

Mistake here is the CPython version. It’s 3.16+, see [gh-157487: Add structured version info for ctypes by serhiy-storchaka · Pull Request #157488 · python/cpython · GitHub](https://github.com/python/cpython/pull/157488).

---

<div class="post-metadata">

**Author:** ![tkacvins](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@tkacvins](https://discuss.python.org/u/tkacvins)\
**Post date:** [December 2, 2026, 12:33am UTC](https://discuss.python.org/t/libffi-and-ctypes-libffi-version/110410/3 "2026-12-02T00:33:30Z")

</div>

OK, I looked over the PR and see that it uses `FFI_VERSION_NUMBER`, which is a compile time constant. However, in the case that one has a product with an embedded Python interpreter which uses `ctypes` built with the system `libffi` and this product is run on a different system which has a system `libffi` that matches in shared library names (`libffi.so.8`, for instance) they might have a different underlying version for `libffi.so.8`. So, I suppose what I am after is what is done with `lxml`

```python
>>> from lxml import etree
>>> etree.LIBXML_VERSION
(2, 14, 6)
>>> etree.LIBXML_COMPILED_VERSION
(2, 14, 6)
>>> etree.LIBXSLT_VERSION
(1, 1, 43)
>>> etree.LIBXSLT_COMPILED_VERSION
(1, 1, 43)

```

So you can see how `libxst` and `libxml2` were used when compiling `lxml.etree` versus what is being used at run time. This would depend on the run time `libffi` library exposing `ffi_get_version` and `ffi_get_version_number` and have those called from `_ctypes`. Linux has these by default. On Windows, the `libffi-8.dll` (at least in the one distributed with Python 3.15.2) doesn’t have these symbols in its export table, so there would be no joy in accessing them from `_ctypes.c` (or related files). Which is why I mentioned `vcpkg` for building `libffi` on Windows, as this makes sure those symbols are exported.
