I have some C code I'd like to wrap and call in python via ctypes.
//example.c
#include <stdio.h>
#include "example.h" //contains foo() declaration.
void foo(){
printf("Hello World!\n");
}
Using the visual studio command line compiler I created a .dll
file.
cl /LD example.c
which created a file called example.dll
.
I then attempt to call foo in python like this:
# example.py
import os
os.add_dll_directory(os.getcwd())
from ctypes import *
read_dll = WinDLL('example.dll')
foo = read_dll.foo #AttributeError: function 'foo' not found
And I get the Error Message: AttributeError: function 'foo' not found
from the final line of example.py