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.
Mailing lists / fpc-pascal / 2005-11
How to make a binding or wrapper ?
4 messages · 4 people · –
- FFelipe Monteiro de Carvalho 1
- KKoenraad Lelong 1
- LL 1
- MMalcolm Poole 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Koenraad Lelong wrote 6 lines
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). =)
On Mon, 14 Nov 2005 21:03 , Koenraad Lelong 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
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?
