<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hello everybody.<br><br>Here next episode of the conversion of a useful fp unit into a universal library...<br><br>The goal is to make a library from a unit used by programs.<br>That unit has lot of complicated procedures-functions, inside some home-made classes, using many dynamic arrays who vary in length and data in real time. Also that procedures call other procedures from foreign dynamic loaded libraries and sent it back to other foreign libraries (after some modification by self-unit of course).<br><br>Lets call that unit 'myunit'.<br><br>Here first working steps: please advice if im on the wrong way... Many thanks.<br><br>1) Create a new file, name it mylib.pas and add this :<br><br>library mylib ;<br><br>use<br>myunit; /// the famous unit with all the procedures/functions, classes,...<br><br>begin<br>end.<br><br>(You have already done all the work !)<br><br>2) Add the functions-procedures you want from myunit in your library-code:<br><br>- Here example for general procedure, not inside a class:<br><br>library mylib ;<br><br>uses<br>myunit;<br><br>procedure mylibprocedure(); cdecl;<br>begin<br> myunit.myprocedure(); /// a general procedure<br>end; <br><br>exports <br>mylibprocedure ;<br> <br>begin<br>end.<br><br>- Here example for function inside a class of myunit:<br><br>library mylib ;<br><br>uses<br>myunit;<br><br>function mylibclassfunction() : integer; cdecl;<br>var<br>myclass : TMyUnitClass; /// class defined in myunit (if can be a variable outside the function)<br><br>begin<br> result := -1 ;<br> myclass := TMyUnitClass.Create; <br> result := myclass.myunitclassfunction() ; // a function of myclass <br>end;<br><br>exports <br>mylibclassfunction ;<br> <br>begin<br>end.<br><br>3) Add this compiler option : -fPIC (otherwise it does not compile on my 64 bit Linux)<br><br>4) Cross your fingers and compile it.<br><br>... And you know what : it compiles and it works ! <br><br>I’m very happy with fpc, all is simple and accessible.<br><br>And, with the recent optimizations, fpc is formula 1 (f1pc)...<br><br>...............<br><br>Now the boring question : <br>Is it normal, even without debug-infos, with -Xs parameters, stripped,... that this library :<br><br>Library test ;<br>begin<br>end;<br><br>is 200k big ! ( mine, nude, only with "uses uos" is more than 1 mega ! ).<br><br>Many thanks for wonderful f1pc.<br><br>Fred<br> </div></body>
</html>