Absolute Minimal Example
This is on Linux. As I write this I'm not sure how things are different with Windows, Cygwin and macos.
The C (in mylib.c):
#include <stdio.h>
void print_number(int n) {
printf("%d\n",n);
}
Compile with
gcc -shared -o mylib.so mylib.c
The Python
import ctypes
lib = ctypes.cdll.LoadLibrary("./mylib.so")
lib.print_number(42)