Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Packaging a caml library a DLL
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Packaging a caml library a DLL
> List,
> I'm having a lot of trouble packaging a caml library (Ensemble) as a
> DLL on win32.  Creating a win32 static library is easy, shared libraries
on
> Unix
> are a breeze, however, win32 DLLs are really problematic.
>
>    Has anybody been able to do this? any example makefiles?

Here's the Makefile Harry Chomsky & me are using for the Win32 API.
Look at "dynamic" built.
It's working without any problem with bytecode compilation. However, native
compilation with DLL won't work due to the need to link with ocamlrun.lib.

Nicolas Cannasse

----------------

CFLAGS=-ccopt /W3 -ccopt /YX -ccopt /Fpwin32.pch
WINLIBS=user32.lib gdi32.lib shell32.lib advapi32.lib comctl32.lib
comdlg32.lib
CCWINLIBS=-cclib user32.lib -cclib gdi32.lib -cclib shell32.lib -cclib
advapi32.lib -cclib comctl32.lib -cclib comdlg32.lib
EXTFLAGS= -I ext

MODULES=  win32_bitmap.+ ..... ( other C files )

######################################################################
# TARGETS :

all : static dynamic opt mkwinapp

static : libwin32.lib win32.cma lkwinapp.obj test_static.exe

dynamic : dllwin32.dll win32.cma test_dynamic.exe

opt : libwin32.lib win32.cmxa lkwinapp.obj test_opt.exe

mkwinapp : mkwinapp.exe

######################################################################
# BUILDS :

libwin32.lib : win32_core.sobj $(MODULES:+=sobj)
    -@del $@ 2>NUL
    lib /out:$@ $**

dllwin32.dll : win32_core.dobj $(MODULES:+=dobj)
    -@del $@ 2>NUL
    link $(WINLIBS) ocamlrun.lib /dll /out:$@ $**

win32.cma : win32_core.cmo $(MODULES:+=cmo) win32.cmo
    ocamlc -a -o $@ -cclib -lwin32 $(CCWINLIBS) -dllib dllwin32 $**

win32.cmxa : win32_core.cmx $(MODULES:+=cmx) win32.cmx
    ocamlopt -a -o $@ -cclib -lwin32 $(CCWINLIBS) $**

win32_core.cmi : win32_core.mli
    ocamlc -c $**

win32_core.cmo : win32_core.cmi win32_core.ml

win32_core.cmx : win32_core.cmi win32_core.ml

win32.cmo : win32_core.cmo $(MODULES:+=cmo) win32.ml

win32.cmx : win32_core.cmx $(MODULES:+=cmx) win32.ml

mkwinapp.exe : mkwinapp.ml
    ocamlc -o $@ unix.cma $**

test_static.exe : win32.cma test.ml test_res.obj libwin32.lib lkwinapp.obj
    ocamlc -o $@ -custom win32.cma test.ml test_res.obj lkwinapp.obj

test_dynamic.exe : win32.cma testnores.ml
    ocamlc -o $@ win32.cma testnores.ml

test_opt.exe : win32.cmxa test.ml test_res.obj libwin32.lib lkwinapp.obj
    ocamlopt -o $@ win32.cmxa test.ml test_res.obj lkwinapp.obj

######################################################################
# SUFFIXES :

.c.obj :
    ocamlc $(CFLAGS) $*.c

.c.sobj :
    ocamlc $(CFLAGS) -ccopt /Fo$@ $*.c

.c.dobj :
    ocamlc $(CFLAGS) -ccopt /Fo$@ -ccopt /MD $*.c

.rc.obj :
    rc $*.rc
    cvtres /machine:ix86 $*.res
    @del $*.res

.ml.cmo :
    ocamlc $(EXTFLAGS) -c $*.ml

.ml.cmx :
    ocamlopt $(EXTFLAGS) -c $*.ml

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners