[lazarus] Building multiple projects

SteveG steveg at nevets.com.au
Wed Mar 26 11:08:20 EST 2003


Tony - have attached an extract of code I use for dynamic library 
loading/usage - should work ok - let me know if questions on use


Tony Maro wrote:
> On that note, I've built several programs that made extensive usage of BPL 's but I have not built anything that used normal libraries. I've been thinking  about Using a library to handle the reports for CBT. Unfortunately I am not sure of how to write a library, and there is no wizard in Lazarus. I also am concerned with the fact that I don't want to install the library on the end-user's computer in the libs  directory, but leave it right with the executable. I've had problems figuring out the exe path before, especially when launched from a shortcut. 
> 
> Does anyone have any example code I could look at? 
> 
> -Tony 
> -----Original Message-----
>     From: "SteveG"<steveg at nevets.com.au>
>     Sent: 3/26/03 3:18:17 AM
>     To: "Lazarus Mailing List"<lazarus at miraclec.com>
>     Subject: [lazarus] Building multiple projects
>     
>     I am working on a program with 1 executable and many librarys (all from 
>     Lazarus) - all need rebuilding if any changes made
>     Is it possible within Lazarus to re-build multiple projects with one 
>     command as yet?
>     
>     Thanks
>     
>     PS
>       It would be a good idea for the Lazarus website to have somewhere for
>     users/developers as myself to be able to indicate our interest and 
>     support. Would show number of people actually using Lazarus ?
>     
>     _________________________________________________________________
>          To unsubscribe: mail lazarus-request at miraclec.com with
>                     "unsubscribe" as the Subject
>        archives at http://www.lazarus.freepascal.org/mailarchives
> 
> _________________________________________________________________
>      To unsubscribe: mail lazarus-request at miraclec.com with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives
> 



interface

{$LinkLib dl}                                                                                                   // Link with "libdl.so"
  function dlopen(  SOFileName :PChar; Flag :Integer ) :Pointer; cdecl; external;                               // open library routine
  function dlsym(   SOAddress :Pointer; IdentifierName :PChar) :Pointer; cdecl; external;                       // rtn routine addr within library
  function dlclose( SOAddress :Pointer ) :Integer; cdecl; external;                                             // unload library

var
  LibAddr   :pointer;                                                               				// Address of the loaded shared object
  LibCmd    :function ( FUNCTION DEF ) :FUNCTION DEF;								// same as definition in library

procedure LoadLibrary;
begin
  LibAddr := dlopen( 'full path to library/libLIBRARYNAME.so', 1 );
  if LibAddr = Nil then begin WriteLn('Unable to Load Library'); Halt; end;

  // set routine pointer to Library Function
  pointer( CmdOut ) := dlsym( LibAddr, 'FUNCTION NAME' );							// lib function (with quotes)
  if pointer( CmdOut ) = Nil then begin
    WriteLn('Function not found');
    dlclose( LibAddr );    											// unload library
    Halt;
  end;
end;

procedure UnLoadLibrary;
begin
  if LibAddr <> Nil then dlclose( LibAddr );									// unload library
end;
 





More information about the Lazarus mailing list