[pypy-commit] cffi default: ffi.dlopen(None) does not work on Windows, and ffi.dlopen("foo") no

arigo noreply at buildbot.pypy.org
Wed Jun 3 08:30:27 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r2160:1a2efa6a7f27
Date: 2015-06-03 08:31 +0200
http://bitbucket.org/cffi/cffi/changeset/1a2efa6a7f27/

Log:	ffi.dlopen(None) does not work on Windows, and ffi.dlopen("foo") no
	longer works generally.

diff --git a/doc/source/overview.rst b/doc/source/overview.rst
--- a/doc/source/overview.rst
+++ b/doc/source/overview.rst
@@ -82,9 +82,19 @@
 
     from _simple_example import ffi
 
-    lib = ffi.dlopen(None)         # or path to a library
+    lib = ffi.dlopen(None)        # or path to a library (see below for Windows)
     lib.printf(b"hi there, number %d\n", ffi.cast("int", 2))
 
+Note that this ``ffi.dlopen()``, unlike the one from in-line mode,
+does not invoke any additional magic to locate the library: it must be
+a path name (with or without a directory), as required by the C
+``dlopen()`` or ``LoadLibrary()`` functions.  This means that
+``ffi.dlopen("libfoo.so")`` is ok, but ``ffi.dlopen("foo")`` is not.
+In the latter case, you could replace it with
+``ffi.dlopen(ctypes.util.find_library("foo"))``.  Also, on
+Windows, passing None to open the standard C library does not work;
+try instead ``ffi.dlopen(ctypes.util.find_library("c"))``.
+
 For distribution purposes, remember that there is a new
 ``_simple_example.py`` file generated.  You can either include it
 statically within your project's source files, or, with Setuptools,


More information about the pypy-commit mailing list