Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-10

Dynamic linking variables

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello List,

I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and dynamic linking (depending on the define). I found out that I require to link two variables with the library.
How can dynamic link a variable using FPC ?

Thanks,
Ido

Reply by email

Henry Vermaak
to ik
ik wrote 6 lines
Hello List, I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and dynamic linking (depending on the define). I found out that I require to link two variables with the library. How can dynamic link a variable using FPC ?

on unix you can use GetProcedureAddress in dynlibs to get any exported symbol (according to the docs, at least). dunno about windows, though.

maybe you need to patch the library source to add helper functions that return those variables.

Show quoted text 5 lines
Thanks, Ido -- http://ik.homelinux.org/

henry

Reply by email

Marc Santhoff
to ik: I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and dynamic linking…
ik wrote 6 lines
Hello List, I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and dynamic linking (depending on the define). I found out that I require to link two variables with the library. How can dynamic link a variable using FPC ?

If you're talking about a variable in a dynamically linked lib declaring like this

  myvar: integer; cvar; external;

should do. If you want to load a library dynamically at runtime using LoadLibrary/dlload, I don't know.

HTH,
Marc

Reply by email

ik
to Marc Santhoff
Marc Santhoff wrote 17 lines
Am Donnerstag, den 25.10.2007, 11:12 +0200 schrieb ik: > Hello List, > > I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and > dynamic linking (depending on the define). I found out that I require > to link two variables with the library. > How can dynamic link a variable using FPC ? If you're talking about a variable in a dynamically linked lib declaring like this myvar: integer; cvar; external; should do. If you want to load a library dynamically at runtime using LoadLibrary/dlload, I don't know.

Yes, that's what I was asking :)

Show quoted text 5 lines
HTH, Marc

Thanks,
Ido

Reply by email

Michael Van Canneyt
to ik
ik wrote 20 lines
On 10/25/07, Marc Santhoff wrote: > Am Donnerstag, den 25.10.2007, 11:12 +0200 schrieb ik: > > Hello List, > > > > I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and > > dynamic linking (depending on the define). I found out that I require > > to link two variables with the library. > > How can dynamic link a variable using FPC ? > > If you're talking about a variable in a dynamically linked lib declaring > like this > > myvar: integer; cvar; external; > > should do. > > If you want to load a library dynamically at runtime using > LoadLibrary/dlload, I don't know. Yes, that's what I was asking :)

You cannot do this with a single construct; You need a pointer in the case of a dynamically loaded library.

Michael.

Reply by email

ik
to Michael Van Canneyt
Michael Van Canneyt wrote 27 lines
On Thu, 25 Oct 2007, ik wrote: > On 10/25/07, Marc Santhoff wrote: > > Am Donnerstag, den 25.10.2007, 11:12 +0200 schrieb ik: > > > Hello List, > > > > > > I'm binding FAM/GAM to Pascal, and I do it in two flavors: static and > > > dynamic linking (depending on the define). I found out that I require > > > to link two variables with the library. > > > How can dynamic link a variable using FPC ? > > > > If you're talking about a variable in a dynamically linked lib declaring > > like this > > > > myvar: integer; cvar; external; > > > > should do. > > > > If you want to load a library dynamically at runtime using > > LoadLibrary/dlload, I don't know. > > Yes, that's what I was asking :) You cannot do this with a single construct; You need a pointer in the case of a dynamically loaded library.

I'm not sure that I understand. can you please point me to an example ?

Michael.

Thanks,
Ido

Reply by email

L
You cannot do this with a single construct; You need a pointer in the case of a dynamically loaded library. > > I'm not sure that I understand. can you please point me to an example ?

He means it depends on whether you are using:

DLL bound dynamically at program runtime
DLL bound statically at program load time

A static DLL is when you use:

procedure blah; external somedll;

Whereas a dynamic DLL is:

LoadLibrary(somedll);
GetProcAddress('blah');

If you are using static binded DLL, then you can use the cvar.. but if using dynamic binded DLL then you have to figure up a different solution.

Reply by email