I'm trying to import function written in c code into python. A minimal example I have tried is //test.h __declspec(dllexport) int HW(int, int); //test.c #include <stdio.h> #include <stdlib.h> #include "test.h" __declspec(dllexport) int HW(int a, int b) { return a + b; } I also tried to remove the __declspec(dllexport) in either files. Then I did the following in Visual Studio 2019 CMD cl /LD test.c or cl /LD test.c \libs\python37.lib In python I did from ctypes import * a = CDLL('test.dll') It turns out that HW is not an attribute of a. Which part did I do wrong? Continue reading...