Difference between revisions of "Creating bindings for C libraries"

From Lazarus wiki
Jump to navigationJump to search
 
Line 1: Line 1:
 
=Overview=
 
=Overview=
  
You have a cool 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) files and now you want to create one or more pascal units to access them.
+
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 function you want to use a pascal function and add the 'external' modifier.  
+
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''.
 
 
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.
 

Revision as of 22:51, 20 September 2006

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.