How to make a binding or wrapper ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make a binding or wrapper ?

Koenraad Lelong-2
Hi,
I'm making an application but to have it work like I want I need to make
a binding or a wrapper (is there a diiference ?) to some external
software. Are there documents that can be used to learn how to do this ?
Regards,
Koenraad Lelong.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: How to make a binding or wrapper ?

Felipe Monteiro de Carvalho
On 11/14/05, Koenraad Lelong <[hidden email]> wrote:
> Hi,
> I'm making an application but to have it work like I want I need to make
> a binding or a wrapper (is there a diiference ?) to some external
> software. Are there documents that can be used to learn how to do this ?
> Regards,
> Koenraad Lelong.

Basicaly the external software can either be:

- A Library (*.dll, *.so, ......)
or
- An Application (*.exe, +x on unix, ...)

I will supose you are talking about libraryes

Linking to a library is easier. You just need to get the header files
for the lib, translate them to pascal, and start using the libs
functions.

The hardware tutorial on the lazarus wiki explains how to link
dinamically on Windows to a library and statically to a glibc
function: http://wiki.lazarus.freepascal.org/index.php/Hardware_Access

Here is an example of the most common link, the static library binding:

function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer):
Integer; cdecl; external 'libc';

The "external" directive tells the compiler the function
implementation is in an external file. In this case "libc.so". Notice
that c functions usually use cdecl calling convention.

Notice that when declaring the function you will need to translate all
those c types to equivalent pascal types (suposing it is a library and
it is written in c). It helps a lot if you know c well.

There are other techniches to talk to an application (DDE, XML via
HTTP, System Messages, ...), but they are so many that you really need
to read the software documentation to find out witch one he uses then
we can go from there.

Basically in order to help more we need to know the nature of the
external software (language and if it is a lib or an app). =)
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: How to make a binding or wrapper ?

Malcolm Poole
In reply to this post by Koenraad Lelong-2


On Mon, 14 Nov 2005 21:03 , Koenraad Lelong <[hidden email]> sent:

>Hi,
>I'm making an application but to have it work like I want I need to make
>a binding or a wrapper (is there a diiference ?) to some external
>software. Are there documents that can be used to learn how to do this ?

I assume that you want to write pascal header files for a library or dll written
in C.
I remember coming across a page somewhere that listed "equivalent structures" in
C and Pascal. I'll see if I can run it down again.

A good way to start otherwise is to compare two easily accessible header files,
for example mysql.h and mysql.pp and use them as a guide. The mysql header files
are fairly simple. For more complex structures I found tha it helped to compare
the Lazarus GTK bindings with their C equivalents.

HTH

Malcolm

---- Message sent via freenetname webmail - http://www.freenetname.co.uk/ Up to 2Mb MAX broadband - now from just £9.99 a month
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
L-9
Reply | Threaded
Open this post in threaded view
|

Re: How to make a binding or wrapper ?

L-9
>Hi,
>I'm making an application but to have it work like I want I need to make
>a binding or a wrapper (is there a diiference ?) to some external
>software. Are there documents that can be used to learn how to do this ?

Your proposition is to general for us to help. Almost everything in software is a
wrapper ;-) All functions are wrappers around something else.
Delphi, is just a wrapper. Freepascal is a wrapper around a number of things.

Exactly what do you want to do?

--
L505

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal