Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Language
English











SourceForge.net Logo



Functions4U Reference. Dl

 

Dl class is an easy way to load dynamic libraries:

Windows: DLL.

Linux: Shared libraries, relocatable files, or programs

 

Public Method List


 

bool Load(const String &fileDl)

Loads library file fileDl before loading its functions. It returns false if error or fileDl does not exist.

fileDl has to contain the full path or has to be included in environment variables:

Windows: PATH

Linux: LD_LIBRARY_PATH

 


 

void *GetFunction(const String &functionName)

It returns a pointer to functionName in the dynamic library or NULL if error or functionName is not in the dynamic library.

 

 

For example, in Windows:

 

Dl adsapi32;

long (*GetDevice)(int);

 

if (!adsapi32.Load(AppendFileName(myDllFolder, "adsapi32.dll")))

    throw Exc(Format(t_("% dll not found"), "Adsapi32"));

 

GetDevice = (long (*)(int))adsapi32.GetFunction("GetDevice");

if (!GetDevice)

    throw Exc(Format(t_("Function %s does not found in dll"), "GetDevice"));

long device = GetDevice(3);

 

 

And in Linux:

 

Dl libm;

double (*cosine)(double);

 

if (!libm.Load("/lib/libm.so.6"))

    throw Exc(Format(t_("% dl not found"), "Libm"));

 

cosine = (double (*)(double))libm.GetFunction("cosine");

if (!cosine)

    throw Exc(Format(t_("Function %s does not found in dl"), "cosine"));

double val = cosine(3.1416);

 

Last edit by koldo on 08/26/2010. Do you want to contribute?. T++