PDA

View Full Version : how to make a library and use it?



noeska
22-02-2009, 07:52 PM
After downloading a tried a hello world and that worked. Next i tried to extend it and make hello world from library out of it. But i cannot get it to work.
How do i write a unit and how do i use it from the main program.
Next how do i make a .dll out of that unit and use it from the main program.
All i get is that an identifier is not existing.
Also should i use namespace or unit/method or procedure?
Thanks for your answers in advance.

noeska
22-02-2009, 08:26 PM
I managed it:



unit HelloLib;

interface

type
MyClass = public static class
public
class procedure Test;
end;

implementation

procedure MyClass.Test();
begin
Console.WriteLine('Hello World From Lib.');
end;

end.




unit HelloWorld;

interface

uses HelloLib;

implementation

procedure Main;
begin
Console.WriteLine('Hello World.');
MyClass.Test();
end;

end.



Oxygene HelloLib.pas /assemblyname:HelloLib /type:library /frameworkfolder:C:\WINDOWS\Microsoft.NET\FrameWork \v2.0.50727
Oxygene Hello.pas /assemblyname:HelloWorld /frameworkfolder:C:\WINDOWS\Microsoft.NET\FrameWork \v2.0.50727 /ref:HelloLib.dll