[ocaml-ctypes] Troubles under windows

Matthieu Dubuget matthieu.dubuget at gmail.com
Thu May 21 14:50:43 BST 2015


Hello,

I'm trying to use ctypes on windows. When I'm trying
#use"ctypes.foreign"
I'm getting a DLL error (see at the end of this message).

My ocaml is x86_64-w64-mingw version.

I did install libffi this way :

tar xaf libffi-3.2.1.tar.gz
cd libffi-3.2.1
./autogen.sh
./configure --host=x86_64-w64-mingw32 --prefix 
/usr/x86_64-w64-mingw32/sys-root/mingw
make
make install

It worked!

$ x86_64-w64-mingw32-pkg-config.exe --list-all
libffi                    libffi - Library supporting Foreign Function 
Interfaces
gsettings-desktop-schemas gsettings-desktop-schemas - Shared GSettings 
schemas for the desktop, including helper headers
autoopts                  AutoOpts - A semi-automated generated/library 
option parser
shared-mime-info          shared-mime-info - Freedesktop common MIME 
database

$ x86_64-w64-mingw32-pkg-config.exe libffi --libs
-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib -lffi

$ x86_64-w64-mingw32-pkg-config.exe libffi --cflags
-I/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libffi-3.2.1/include

I compiled ctypes :

7z x ocaml-ctypes-0.4.1.zip
cd ocaml-ctypes-0.4.1
export LIBFFI_LIBS=$(x86_64-w64-mingw32-pkg-config.exe libffi --libs)
export LIBFFI_CFLAGS=$(x86_64-w64-mingw32-pkg-config.exe libffi --cflags)
make
make install

$ ocaml
         OCaml version 4.02.1

# #use"topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
   #require "package";;      to load a package
   #list;;                   to list the available packages
   #camlp4o;;                to load camlp4 (standard syntax)
   #camlp4r;;                to load camlp4 (revised syntax)
   #predicates "p,q,...";;   to set these predicates
   Topfind.reset();;         to force that packages will be reloaded
   #thread;;                 to enable threads

- : unit = ()

# #require"ctypes.foreign";;
C:\OCaml\lib\unix.cma: loaded
C:\OCaml\lib\bigarray.cma: loaded
C:\OCaml\lib\str.cma: loaded
C:\OCaml\lib\site-lib\bytes: added to search path
C:\OCaml\lib\site-lib\ctypes: added to search path
C:\OCaml\lib\site-lib\ctypes\ctypes.cma: loaded
C:\OCaml\lib\site-lib\ctypes\ctypes-foreign-base.cma: loaded
Cannot load required shared library dllctypes-foreign-base_stubs.
Reason: C:\OCaml\lib\site-lib\ctypes\dllctypes-foreign-base_stubs.dll: 
Cannot resolve ffi_type_pointer.
C:\OCaml\lib\site-lib\ctypes\ctypes-foreign-unthreaded.cma: loaded
Characters -1--1:
   #require"ctypes.foreign";;

Error: Reference to undefined global `Ctypes_closure_properties'


I'm not sure if it can help to understand what the problem is?

$ ldd /cygdrive/c/OCaml/lib/site-lib/ctypes/dllctypes-foreign-base_stubs.dll
Cannot find FLEXDLL_RELOCATE
         ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x76e40000)
         kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll 
(0x76c20000)
         KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll 
(0x7fefcc60000)
         ??? => ??? (0x6e3c0000)
         msvcrt.dll => /cygdrive/c/Windows/system32/msvcrt.dll 
(0x7feff0b0000)
         USER32.dll => /cygdrive/c/Windows/system32/USER32.dll (0x76d40000)
         GDI32.dll => /cygdrive/c/Windows/system32/GDI32.dll (0x7fefed00000)
         LPK.dll => /cygdrive/c/Windows/system32/LPK.dll (0x7fefd740000)
         USP10.dll => /cygdrive/c/Windows/system32/USP10.dll (0x7fefd750000)
         ??? => ??? (0x6b740000)
         ??? => ??? (0x77000000)
         IMM32.DLL => /cygdrive/c/Windows/system32/IMM32.DLL (0x7fefd710000)
         MSCTF.dll => /cygdrive/c/Windows/system32/MSCTF.dll (0x7fefed70000)
         nvinitx.dll => /cygdrive/c/Windows/system32/nvinitx.dll 
(0x7fefcb30000)
         VERSION.dll => /cygdrive/c/Windows/system32/VERSION.dll 
(0x7fefcb20000)
         ADVAPI32.dll => /cygdrive/c/Windows/system32/ADVAPI32.dll 
(0x7fefd280000)
         sechost.dll => /cygdrive/c/Windows/SYSTEM32/sechost.dll 
(0x7feff090000)
         RPCRT4.dll => /cygdrive/c/Windows/system32/RPCRT4.dll 
(0x7fefd040000)
         igdumd64.dll => /cygdrive/c/Windows/system32/NV/igdumd64.dll 
(0x7feed120000)
         SETUPAPI.dll => /cygdrive/c/Windows/system32/SETUPAPI.dll 
(0x7fefd360000)
         CFGMGR32.dll => /cygdrive/c/Windows/system32/CFGMGR32.dll 
(0x7fefcc20000)
         OLEAUT32.dll => /cygdrive/c/Windows/system32/OLEAUT32.dll 
(0x7fefd630000)
         ole32.dll => /cygdrive/c/Windows/system32/ole32.dll (0x7fefee80000)
         DEVOBJ.dll => /cygdrive/c/Windows/system32/DEVOBJ.dll 
(0x7fefcf20000)
         igd10umd64.dll => 
/cygdrive/c/Windows/system32/NV/igd10umd64.dll (0x7feec200000)

Thanks for any help!

-- 
Matthieu Dubuget



More information about the Ctypes mailing list