Skip to content Skip to sidebar Skip to footer

Scipy / Ctypes Build-config: How To Load Lib?

These docs have a nice example on how to compile some external C/C++ code and load this using ctypes. This works great with manual compilation (where i'm controlling the names of m

Solution 1:

Inspired by numpy's sources, i'm now able to load the lib using:

import scipy as scp
import numpy.ctypeslib as ctl
lib = ctl.load_library('_mylib', scp.optimize.__file__)  # thisis the magical line
myfunc = lib.myfunc

Well... at least in theory!

Against my prior assumption, my lib-build is not equivalent to a manual-compile and the function i want to load is not available (undefined symbol: myfunc). But the problem of locating the lib feels clean now and is solved for me.

Post a Comment for "Scipy / Ctypes Build-config: How To Load Lib?"