'Python Compile Mixed C and C++ Extension

I'm attempting to compile libspng with PyBind11 so I can easily convert image data into a numpy array.

The compilation process requires compiling a few C files and then linking them to C++. However, I'm not sure how to do this with Python setuptools. I've so far been compiling all C++ or all C modules in my practice, but on clang, this results in problems when I mix the pybind11 file with the C files.

Is there a simple way that I'm missing to compile and link the C files to C++ within setup.py?

I tried building an extension for libspng, but I wasn't sure how to reference the compiled shared object file which was in the build folder.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source