> For the complete documentation index, see [llms.txt](https://docs.hex-rays.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hex-rays.com/core/types/how-tos/creating-type-libraries/tilib.md).

# TILIB

TILIB is a utility to create custom type libraries for IDA Pro. Since IDA 9.1, TILIB is shipped with IDA, in the `tools` folder within the main IDA installation directory.

This small utility creates type library (til) files for IDA Pro. Its functionality overlaps with "Parse C header file...". However, TILIB can also preserve preprocessor macro definitions in type libraries and convert selected numeric macros into enums. IDA’s "Parse C header file..." command processes macros while parsing declarations, but does not import those macros as named constants.

The utility takes a C/C++/Obj-C header file and extracts all type information from it. The extracted type information is stored in an internal format as a type library file. Type library files can be loaded and used in IDA Pro by opening the Type Library Window and pressing Insert.

## Installation

Copy the `tilib` executable file into the IDA Pro directory.

TILIB uses the IDA Pro kernel library and needs nothing else from the installation. Copying the executable into the IDA Pro directory is the simplest way to let it find the library; if you prefer to keep it elsewhere, make the library reachable through the usual library search path of your system.

## Usage

If started without parameters, the utility displays a short explanation. Below are some command line samples.

Parse a header file and create a new type library:

```
tilib -c -hinput_header_file output_til_file
```

* `-c` means to create a new type library
* `-h` denotes the name of the input file to read

If you need to parse multiple files into one type library, you may create a text file with #include directives and specify it as the input.

TILIB can handle input files for Visual Studio, Borland, GCC out of the box. Please check the configuration files for them in the archive (\*.cfg).

If you need to fine-tune TILIB for another compiler (or unusual compiler settings), feel free to copy the provided configuration files and modify them.

TILIB is not very good at error handling and some error messages may be quite unhelpful (e.g. syntax error). To alleviate this problem, use the `-z` switch. If this switch is specified, TILIB creates a .i file with the preprocessed contents. All recognized type names are prepended with @, like this: @my\_type\_name.

In some urgent cases, the `-e` switch may be used to ignore any parsing errors. Please note that the problematic type definitions will be skipped in this mode. This switch may be used together with the -R switch to allow type redeclarations.

If your input file uses another header file (e.g. windows.h), you may opt to use the vc6win.til file instead of parsing it again. For that, just use the `-b` switch and specify vc6win.til as the base til. TILIB loads the contents of the specified file into the memory and parses the input file. All definitions from windows.h, including the preprocessor definitions, are available:

```
tilib -c -hinput_header_file -bbase_til_file output_til_file
```

TILIB can also be used to list the contents of a til file:

```
tilib -l input_til_file
```

If the `-c` switch is not specified, TILIB uses the specified til file as the input and as the output file. This mode allows you to modify existing til files.

## Building type libraries with TILIB

TILIB is a utility to create custom type libraries for IDA Pro. You can find it in the `tools` folder within the main IDA installation directory. For an overview just run `tilib`.

### Basic examples

Important flags:

* `-TC` - enables the clang parser
* `-P` - enables C++ mode
* `-I` - is used to specify include directories
* `-CT` - is used to specify additional clang arguments, for example `-std=c++20` for C++20 code
* `-v` - you'll see `CLANG command line:` printed, which is the easiest way to debug your configuration

#### C++

```
tilib -ch/path/to/header.hpp -TC -P -CT-std=c++20 -I/path/to/includes out.til
```

#### Objective-C

```
tilib -ch/path/to/header.h -TC -CT-xobjective-c -I/path/to/SDK/usr/include out.til
```

#### Objective-C++

```
tilib -ch/path/to/header.mm -TC -CT-xobjective-c++ -I/path/to/SDK/usr/include out.til
```

### Complex type libraries

#### Qt

This example will be given using macOS and Qt 6.

To install Qt, one can use Homebrew:

```
brew install qt
```

For convenience, you can set some environment variables. These may vary based on your system and Qt installation.

```sh
export QTDIR=/opt/homebrew/opt/qt@6
export SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
export CLANG_HDRS=/Library/Developer/CommandLineTools/usr/lib/clang/17/include
```

Create an umbrella header (qt.h):

```cpp
#include <QtCore>
#include <QtGui>
#include <QtWidgets>
#include <QtPrintSupport>
#include <QtNetwork>
#include <QtConcurrent>
#include <QtDBus>
#include <QtHelp>
#include <QtOpenGL>
#include <QtSql>
#include <QtTest>
#include <QtUiTools>
#include <QtXml>
```

Create the type library:

```
tilib -c -TC -P \
  -t"Qt 6 headers for arm64 macOS" \
  -CT--target=arm64-apple-darwin \
  -CT-xobjective-c++ \
  -CT-std=c++20 \
  -CT-stdlib=libc++ \
  -CT-isysroot -CT$SDK \
  -CT-idirafter -CT$CLANG_HDRS \
  -CT-F$QTDIR/lib \
  -CT-Wno-nullability-completeness \
  -I$QTDIR/lib/QtCore.framework/Headers \
  -I$QTDIR/lib/QtGui.framework/Headers \
  -I$QTDIR/lib/QtWidgets.framework/Headers \
  -I$QTDIR/lib/QtPrintSupport.framework/Headers \
  -I$QTDIR/lib/QtNetwork.framework/Headers \
  -I$QTDIR/lib/QtConcurrent.framework/Headers \
  -I$QTDIR/lib/QtDBus.framework/Headers \
  -I$QTDIR/lib/QtHelp.framework/Headers \
  -I$QTDIR/lib/QtOpenGL.framework/Headers \
  -I$QTDIR/lib/QtSql.framework/Headers \
  -I$QTDIR/lib/QtTest.framework/Headers \
  -I$QTDIR/lib/QtUiTools.framework/Headers \
  -I$QTDIR/lib/QtXml.framework/Headers \
  -hqt.h qt_mac_arm64.til
```

Note that sometimes there may be inconsistencies between IDA's clang and the system's clang, which may cause parsing errors. For example, if Apple's clang header files use some features that are not supported by the LLVM clang, you may need to add some additional flags to the command line to work around the issue. You can use `-v` to see the exact command line used for parsing and debug the problem. However, if that doesn't work and the parser gets in your way, you can also pass `-e` in order to ignore potential parsing errors and get as much of the type information as possible. You'll likely still extract a good amount of useful information.

To verify what has been parsed into the type library, dump the information using `tilib -lc qt_mac_arm64.til > qt_mac_arm64.txt`.

#### XNU Kernel

If you're on a macOS system, this is pretty straightforward, since you can use the system's SDK and clang headers.

```
export SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
```

Create `xnu.h` and include your headers of interest:

```cpp
#include <IOKit/IOTypes.h>
#include <IOKit/IOConditionLock.h>
#include <IOKit/IONVRAM.h>
#include <IOKit/IOEventSource.h>
#include <IOKit/IOUserClient.h>
#include <IOKit/IOMemoryCursor.h>
#include <IOKit/IONotifier.h>
#include <IOKit/IOServicePM.h>
#include <IOKit/IOKitDebug.h>
#include <IOKit/IODMACommand.h>
#include <IOKit/IOMapTypes.h>
#include <IOKit/IOBSD.h>
#include <IOKit/IOService.h>
#include <IOKit/IORegistryEntry.h>
#include <IOKit/IOPlatformExpert.h>
#include <IOKit/IOKitKeys.h>
#include <IOKit/IOMapper.h>
#include <IOKit/IOMessage.h>
#include <IOKit/IOReturn.h>
#include <IOKit/IOSubMemoryDescriptor.h>
#include <IOKit/IOReportTypes.h>
#include <IOKit/IOServiceStateNotificationEventSource.h>
#include <IOKit/IODataQueue.h>
#include <IOKit/IOCommandGate.h>
#include <IOKit/IODataQueueShared.h>
#include <IOKit/PassthruInterruptController.h>
#include <IOKit/IOCommand.h>
#include <IOKit/IOCatalogue.h>
#include <IOKit/IODMAController.h>
#include <IOKit/IOInterruptEventSource.h>
#include <IOKit/IOReportMacros.h>
#include <IOKit/IOInterleavedMemoryDescriptor.h>
#include <IOKit/IOKernelReportStructs.h>
#include <IOKit/IOBufferMemoryDescriptor.h>
#include <IOKit/IOSharedLock.h>
#include <IOKit/IOUserServer.h>
#include <IOKit/IOTimeStamp.h>
#include <IOKit/IOSharedDataQueue.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IORPC.h>
#include <IOKit/IODeviceMemory.h>
#include <IOKit/IORangeAllocator.h>
#include <IOKit/IOLocks.h>
#include <IOKit/IOLib.h>
#include <IOKit/IOMemoryDescriptor.h>
#include <IOKit/IOKitServer.h>
#include <IOKit/IOGuardPageMemoryDescriptor.h>
#include <IOKit/IOCommandPool.h>
#include <IOKit/IOInterrupts.h>
#include <IOKit/IOInterruptController.h>
#include <IOKit/IOTimerEventSource.h>
```

You can check your OS version and the corresponding SDK version using `sw_vers`.

```
ProductName:		macOS
ProductVersion:		26.3.1
ProductVersionExtra:	(a)
BuildVersion:		25D771280a
```

Creating the type library for Darwin Kernel headers of macOS 26.3:

```
tilib -c -TC -P \
  -t"Darwin Kernel headers for arm64 macOS" \
  -CT--target=arm64-apple-macos26.3 \
  -CT-isysroot -CT$SDK \
  -CT-nostdinc \
  -CT-std=gnu++1z \
  -CT-stdlib=libc++ \
  -CT-mkernel \
  -DKERNEL \
  -DAPPLE \
  -DNeXT \
  -I$SDK/System/Library/Frameworks/Kernel.framework/Headers \
  -hxnu.h xnu_mac_arm64.til
```

#### macOS/iOS SDK

The same process can be applied to create type libraries for macOS or iOS SDKs. Just make sure to set the right target and include paths.

```
export SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
export CLANG_INC=$(ls -1d /Library/Developer/CommandLineTools/usr/lib/clang/*/include | sort -V | tail -1)
```

An umbrella header (macos\_sdk.h) can be found here:

{% file src="/files/qwwq04VuLuzWTWbCCzTK" %}

.

Here's a recipe of how to generate the umbrella header on your system:

```sh
SDK=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
for f in $SDK/System/Library/Frameworks/*.framework; do
  mm="$f/Modules/module.modulemap"
  [ -f "$mm" ] || continue
  uh=$(awk '/umbrella header/{gsub(/"/,"",$3); print $3; exit}' "$mm")
  fw=$(basename "$f" .framework)
  case "$fw" in _*) continue;; esac
  [ -n "$uh" ] || continue
  hdr="$f/Headers/$uh"
  grep -lq "UIKit/UIKit.h" "$hdr" 2>/dev/null && continue
  echo "#include <$fw/$uh>"
done > macos_sdk.h
```

Generate the type library for macOS:

```
tilib -c -TC \
  -t"macOS SDK headers for arm64" \
  -CT--target=arm64-apple-darwin \
  -CT-x -CTobjective-c++ \
  -CT-isysroot -CT$SDK \
  -CT-isystem -CT$CLANG_INC \
  -CT-ferror-limit=0 \
  -CT-Wno-nullability-completeness \
  -D__ARM_NEON_H \
  -hmacos_sdk.h macos_sdk_arm64.til
```

For iOS, change the SDK path and the target:

```
export SDK=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
```

Example TILIB command:

```
$TILIB -c -TC \
  -t"iPhoneOS SDK headers for arm64" \
  -CT--target=arm64-apple-ios \
  -CT-x -CTobjective-c++ \
  -CT-isysroot -CT$SDK \
  -CT-isystem -CT$CLANG_INC \
  -CT-ferror-limit=0 \
  -CT-Wno-nullability-completeness \
  -D__ARM_NEON_H \
  -hios_sdk.h ios_sdk_arm64.til
```

Use `-v` (verbose) or `-e` (ignore errors) if you run into issues.

## How to create preprocessor macro enums?

TILIB can also convert selected preprocessor macros into enums. If the input file has lines like the following:

```
#define MY_SYMBOL_ONE   1
#define MY_SYMBOL_TWO   2
#define MY_SYMBOL_THREE 3
```

they can be converted to enum and used in IDA Pro. This is a three step process. At the first step, you create a .mac file (note the `-M` switch):

```
tilib -c -Moutput_mac_file -hinput_header_file output_til_file
```

The second step is to edit the generated .mac file: to remove undesired macro definitions and regroup macros if necessary. Macro group names start at the beginning of a line, symbol definitions are indented:

```
MY_SYMBOL
  MY_SYMBOL_ONE   1
  MY_SYMBOL_TWO   2
  MY_SYMBOL_THREE 3
```

Feel free to edit the macro file to your taste.

It is also possible to describe the changes to the macro group names and rerun TILIB to regenerate the macro file. There are two ways to describe the changes:

1. Through the -g\[nb]X:Y command-line options. If the regex X matches the macro name (n) or the macro body (b), the group is set to Y. For example:

   ```
   tilib -gnFOO_:ERRORS -gbERR:ERRORS -c -Moutput_mac_file -hinput_header_file output_til_file
   ```

   with this header file:

   ```
   #define ERR(x)  x
   #define FOO_OK  0
   #define FOO_BAD 1
   #define BAR_BAD ERR(-1)
   ```

   produces this macro file:

   ```
   ERRORS
   FOO_OK 0
   FOO_BAD 1
   BAR_BAD -1
   ```

   An empty regex prevents the group from being created (useful when you want to leave a group name available from a base til).
2. Adding a TILIB-specific #pragma to the header files:

   ```
   #pragma tilib-group ERRNO
   // all macros before resetting tilib-group will be added to the ERRNO group
   #include <errno.h>
   #pragma tilib-group
   ```
3. The third and last step is to specify the macro file as the input for TILIB:

   ```
   tilib -c -minput_mac_file -hinput_header_file output_til_file
   ```

The generated til file has all normal type definitions and all macro definitions from the .mac file.

## List of supported keywords

Below is the list of supported keywords. If your header files happen to have an unsupported keyword, you can take one of the following actions:

* edit the input files and remove the unsupported keywords
* use #define to replace or hide the unsupported keywords
* use the -D command line switch for the same purpose

```
__cdecl     do       goto      return     protected      __ptr32
__pascal    if       long      signed     __unaligned    __ptr64
__stdcall   _es      cpp_this  sizeof     __userpurge    __restrict
__fastcall  _cs      void      static     _BYTE          __hidden
__thiscall  _ss      break     struct     _WORD          __array_ptr
__usercall  _ds      catch     switch     _DWORD         __struct_ptr
__export    asm      class     default    _QWORD         __return_ptr
__import    for      const     mutable    _OWORD
__thread    int      float     private    _TBYTE
__declspec  new      short     typedef    _UNKNOWN
__far       try      throw     virtual    _BOOL1
__near      auto     union     continue   _BOOL2
__huge      bool     while     register   _BOOL4
__int8      case     double    template   __spoils
__int16     char     extern    unsigned   __attribute__
__int32     else     friend    volatile   __pure
__int64     enum     inline    interrupt  __noreturn
__int128    flat     public    namespace  __cppobj
```

## What's next?

Learn more about TILIB utility and check [Igor's tip of the week](https://hex-rays.com/blog/igors-tip-of-the-week-62-creating-custom-type-libraries/) about creating custom libraries.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hex-rays.com/core/types/how-tos/creating-type-libraries/tilib.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
