English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Windows Vista/7 specific functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-09-02 (11:27)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] Windows Vista/7 specific functions
Hi Reed,


                Having hacked away with the Win64 port before I thought I’d have a go. The first thing I noticed is that Microsoft have finally released the x86 and x64 compilers in the same package (this was a pain if you wanted to build MSVC and MSVC64 ports as you needed two SDKs to do it...) – though I haven’t tried building the 32-bit MSVC port from this SDK yet.


                Here’s what I did (you’ll have to excuse my idiosyncratic way of copying binary files into the OCaml tree – these can be replaced with PATH changes if you want. I copy things around so that ocamlopt always works without needing a special build environment or vast compiler suites permanently in my PATH).


                The build is slightly complicated because you need to build flexdll directly. 


                Make sure you have Cygwin base with with Devel\make and Devel\subversion added


                I installed the Win7 SDK to C:\Dev\WinSDK (though it still irritatingly puts the compilers in C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC). I didn’t bother installing Documentation, Samples or the IA64 libraries.


                Add the following to your LIB environment variable:

                                C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\amd64;C:\Dev\WinSDK\lib\x64


                Add the following to your INCLUDE environment variable:

                                C:\Program Files (x86)\Microsoft Visual Studio 9.0\vc\include;C:\Dev\WinSDK\Include


                Set OCAMLLIB to C:\Dev\OCaml-MSVC64\lib


                A whole load of files now get copied to C:\Dev\OCaml-MSVC64\bin:

                From C:\Cygwin\bin, copy cygpath.exe and cygwin1.dll (needed by flexlink)

                Extract flexdll.h, default.manifest and flexlink.exe from the flexdll 0.19 x86 binaries (latest flexlink tool – doesn’t need to be x64)

                From C:\Program Files (x86)\Microsoft Visual Studio\9.0\VC\bin\amd64, copy:

                                1033\clui.dll (this needs to be in C:\Dev\OCaml-MSVC64\bin\1033)

                                ml64.exe, cl.exe, c1.dll, c2.dll, cvtres.exe, link.exe and mspdb80.dll

                From C:\Dev\WinSDK\Bin\x64, copy mt.exe


                Or workaround that stupidity by having C:\Cygwin\bin and the other directories in your PATH


                Start Bash (possibly as Administrator depending on permissions set on C:\Dev)

                I placed the ocaml 3.11.1 tarball in C:\Dev\Src-MSVC64


                Note that the sed instruction not only sets PREFIX but it also removes bufferoverflowu.lib from EXTRALIBS – apparently this is no longer needed in this version of the SDK (presumably the compiler has started to include all the required support natively or perhaps the runtime now has it).


                $ cd /cygdrive/c/Dev/Src-MSVC64

                $ svn co svn://frisch.fr/flexdll/trunk flexdll-dev

                $ cd flexdll-dev

                $ make CHAINS=msvc flexdll_msvc.obj flexdll_initer_msvc.obj

                $ cp *.obj /cygdrive/c/Dev/OCaml-MSVC64/bin

                $ cd ..

                $ tar -xzf ocaml-3.11.tar.gz

                $ cd ocaml-3.11

                $ cp config/m-nt.h config/m.h

                $ cp config/s-nt.h config/s.h

                $ sed -e '20s/=.*$/=C:\/Dev\/OCaml-MSVC64/' -e '92s/=.*/=/' config/Makefile.msvc64 > config/Makefile

                $ make -f Makefile.nt world opt opt.opt install


                And you should have a fully working MSVC64 build with the Win7 SDK Compilers (and therefore be able to link against the newer libraries). If you wish, quite reasonably, to be a purist and have everything 64-bit you can now go back to flexdll-dev and say:


                $ sed -i -e 's/"afxres.h"/<windows.h>/' version.rc

                $ rc version.rc

                $ cvtres /nologo /machine:amd64 /out:version_res.obj version.res

                $ make version.ml

                $ ocamlopt -o flexlink.exe -ccopt "-link version_res.obj" version.ml coff.ml cmdline.ml create_dll.ml reloc.ml

                $ cp flexlink.exe /cygdrive/c/Dev/OCaml-MSVC64/bin


                And you’ll have flexlink.exe as a 64-bit executable as well.








From: caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Reed Wilson
Sent: 02 September 2009 05:44
To: caml-list@yquem.inria.fr
Subject: [Caml-list] Windows Vista/7 specific functions


Hi all,


I am going to be writing a native-code 64-bit program which takes advantage of some Windows Vista-only features (transactional NTFS), and I was wondering how to get it working in OCaml. I have made numerous interfaces to Windows XP functions, but the problem is that the NTFS transactional functions are only available through MSVS 2008 and the Vista/7 SDKs, which OCaml seems to not compile with. I tried using the new Windows 7 SDK tools to compile the program to native code, but it kept giving me errors with not being able to find bufferoverflowu.lib.


Does anybody know if there is any way to compile a 64-bit OCaml with the newer Windows SDKs, or failing that, to at least tell OCaml how to properly link things with them?