Previous Contents Next

4  Using camlidl

4.1  Overview

The camlidl stub generator is invoked as follows:
        camlidl options file1.idl file2.idl ...
For each file f.idl given on the command line, camlidl generates the following files: The generated .ml and .c files must be compiled and linked with the remainder of the Caml program.

4.2  Options

The following command-line options are recognized by camlidl.
-cpp
Pre-process the source IDL files with the C preprocessor. This option is set by default.

-D symbol=value
Define a preprocessor symbol. The option -Dsymbol=value is passed to the C preprocessor. The value can be omitted, as in -D symbol, and defaults to 1.

-header
Generate a C header file f.h containing C declarations for the types and functions declared in the IDL file f.c.

-I dir
Add the directory dir to the list of directories searched for .idl files, as given on the command line or recursively loaded by import statements.

-keep-labels
Keep the Caml names of record labels as specified in the IDL file. Do not prefix them with the name of the enclosing struct, even if they appear in several struct definitions.

-nocpp
Suppresses the pre-processing of source IDL files.

-no-include
By default, camlidl emits a #include "f.h" statement in the file f.c containing the generated C code. The f.h header file being included is either the one generated by camlidl -header, or generated by another tool (such as Microsoft's midl compiler) from the IDL file, or hand-written. The f.h file is assumed to provide all C type declarations needed for compiling the stub code.

The -no-include option suppresses the automatic inclusion of the f.h file. The IDL file should then include the right header files and provide the right type declarations via quote statements.

-prefix-all-labels
Prefix all Caml names of record labels with the name of the enclosing struct. The default is to prefix only those labels that could cause ambiguity because they appear in several struct definitions.

-prepro preprocessing-command
Set the command that is executed to pre-process the source IDL files. The default is the C preprocessor.

4.3  The camlidldll script

Under Windows, a bash script called camlidldll is provided to automate the construction of a DLL containing a COM component written in Caml.

The script camlidldll accepts essentially the same command-line arguments and options as the ocamlc compiler. (It also accepts .tlb type library files on the command-line; see section 6.3, ``Dispatch interfaces'', for more information on type libraries.) It produces a DLL file that encapsulates the Caml and C object files given on the command line.

Use regsvr32 /s file.dll to record the components in the system registry once it is compiled to a DLL.


Previous Contents Next