Creating bindings for C libraries

From Free Pascal wiki
Revision as of 22:51, 20 September 2006 by Mattias2 (talk | contribs)
Jump to navigationJump to search

Overview

You have a C library (for example a .dll or .so) and you want to use it in your pascal program. You only found C header files (.h) and now you want to create one or more pascal units to access them.

FPC can easily use C libraries. For example you only need to provide for every needed function a pascal function and add the 'external' modifier.

For small libraries this can be done manually, but for big libraries with hundreds or thousands of functions, constants, types and variables you should use tools like h2pas.