python - Procedure entry point __gxx_personality_v0 could not be located libstdc++-6.dll -
appreciate question has been asked , answered several cases i'm still having issues. directory structure laid out such:
models/ bs/ __init__.py values.py optlib/ makefile bin/ optlib.so # generated after compilation/linking libstdc++-6.dll inc/ optlib.h stats.h obj/ optlib.o # generated after compilation/linking stats.o # generated after compilation/linking src/ optlib.cc stats.cc
in short, source files in src
, header files in inc
, object files output obj
, shared library file output bin
.
i've compiled , linked c/c++ libraries using following commands (extracted makefile
):
g++ -c -iinc -o obj/optlib.o src/optlib.cc g++ -c -iinc -o obj/stats.o src/stats.cc g++ -shared -wl,-soname,bin/optlib.so -o bin/optlib.so obj/optlib.o obj/stats.o
i'm using mingw on windows 7 machine , attempting access shared library python using ctypes
. i've placed libstdc++-6.dll
file c:\mingw\bin
bin
directory contains shared library, optlib.so
many of posts suggest.
my python code follows (note __init__.py
imports values.py
):
# neither os.path.abspath method of building path works... fn = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'optlib', 'bin', 'optlib.so')) print type(fn) # returns <type 'unicode'> # or implicitly typing out #fn= u'c:\\users\\striji\\desktop\\models\\optlib\\bin\\optlib.so' load_with_altered_search_path=0x00000008 kernel32 = windll('kernel32') kernel32.loadlibraryexw.restype = c_void_p hmod = kernel32.loadlibraryexw(fn, none, load_with_altered_search_path) lib = cdll(fn, handle=hmod) def fcn(x): lib.c_func.argtypes = [c_double] lib.c_func.restype = c_double x = byref(c_double(x)) return lib.c_func(x)
when attempt import module using following:
>>> models import bs
i following error:
c:\mingw\bin
on path
variable. source code c++
wrapped in extern "c"
ctypes
can see it. these simple c++
functions. if need see source, can post.
question twofold. first, how fix immediate problem. second, possible simplify compilation , linking process system agnostic (i.e. compiles , links on mac osx , linux)?
Comments
Post a Comment