---
title: "Using the Slice Compiler"
url: https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler
language: ruby
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Using the Slice Compiler

Programming language: Ruby. Other languages: [C++](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/php.md), [Python](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/python.md), [Swift](https://docs.zeroc.com/ice/3.8/slice/using-the-slice-compiler/swift.md).

## Common Options

Ice provides a Slice compiler for each language mapping. The compilers share a similar command-line syntax:

```shell
slice2<name> [options] file...
```

Regardless of which compiler you use, a number of command-line options are common to the compilers for any language mapping:

- `-h, --help` Displays a help message.
- `-v, --version` Displays the compiler version.
- `-DNAME` Defines the preprocessor symbol `NAME` with the value `1`.
- `-DNAME=DEF` Defines the preprocessor symbol `NAME` with the value `DEF`.
- `-UNAME` Undefines the preprocessor symbol `NAME`.
- `-IDIR` Add the directory `DIR` to the search path for `#include` directives.
- `--output-dir` `DIR` Place the generated files into directory `DIR`, which must already exist.
- `-d, --debug` Print debug information showing the operation of the Slice parser.

The following options print dependency information:

- `--depend` Print dependency information in Makefile format to standard output by default, or to the file specified by the `--depend-file` option.
- `--depend-xml` Print dependency information in XML format to standard output by default, or to the file specified by the `--depend-file` option.
- `--depend-file FILE` Directs dependency information to the specified file. The output format depends on whether `--depend` or `--depend-xml` is specified.

With these options, the compiler prints the complete list of Slice files that the input Slice files depend on, through direct or indirect inclusion, and generates no code.

The Slice compilers permit you to compile more than a single source file, so you can compile several Slice definitions at once, for example:

```shell
slice2cpp -I. file1.ice file2.ice file3.ice
```

Each compiler predefines macros that identify the compiler and the Ice version; see [Conditional Compilation](https://docs.zeroc.com/ice/3.8/slice/slice-source-files.md#conditional-compilation).

## The Slice Compiler for Ruby

The Slice-to-Ruby compiler (`slice2rb`) offers one additional option:

- `--all` Generate code for all Slice definitions, including those from included files.

## See Also

- [Slice Compilation](https://docs.zeroc.com/ice/3.8/slice/slice-compilation.md)
