Loading a DLL from ctypes in blender

I am loading a DLL I comiled with Clang in Blender’s Python as an API for my program. I can successfully load the DLL in python externally and call and extract the data as expected but when I try in blender ctypes returns “Winerror 126 module not found”.
Os.path.exists returns True when I type in the path of the DLL I am loading and I can load an even smaller “Hello World” DLL which only links with the standard libary not a lib, but I am not convinced that is the issue either. I am using a 64 bit DLL too.

Not sure where to go with this.

hard to say without more information, one thing that is different with blender’s python is that it uses a non standard msvcrt runtime (2013 instead of the 2015 mainline python uses) , you could try a vc14 build from https://builder.blender.org/download/ and see if that improves things for you.

I’ve tried it with the new compiler and had the same issue, even with 2.8 it does too which has a newer python version as well.

What more information might help? I’m happy to provide that. I’ll add the source code.

DLLPath = r’c:/Users/Oliver/Documents/Programming/CPP/Payload/build/out/libpayload.dll’
Payload = ctypes.WinDLL(“C:/Users/Oliver/Documents/Programming/CPP/Payload/build/out/libpayload.dll”)

This is the error from blender
Traceback (most recent call last):
File “C:\Users\Oliver\Documents\Programming\CPP\Payload\build\out\teapot.blend\engine.py”, line 12, in
File “C:\Program Files\Blender Foundation\Blender\2.79\python\lib\ctypes_init_.py”, line 347, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
Error: Python script fail, look in the console for now…

try running dependency walker on your dll, to see if there’s any dependencies that it wants but are missing?

Yes I realised after posting that the paths were a bit messed up, the DLL manually loads another DLL which I assumed would be fine but it didn’t seem to be, loading it in blender’s python before the one I wanted worked fine.

Still a bit confused why I didn’t need that in standard python but I’m glad it’s working.