Nathalie Jarosz wrote:
From: "Khimenko Victor" gpc@khim.sch57.msk.ru To: jarosz_n@hotmail.com, gpc@gnu.de Subject: Re: beta distribution Date: Thu, 29 Jun 2000 20:40:28 +0400 (MSD)
So I still have some questions... I have tried with a C routine and the pascal unit and program but it doesn't work.
What exactly you done ? It's really trivial task if you know both C and Pascal and thus it's hard to guess where newbie without C knowleadge can fail...
So, I would like to use a beta random deviates I have in C, in my pascal program. I have downloaded "randlib" which contain this function. In randlib.h, there is: extern float genbet(float aa, float bb);
First, I have written beta.p : unit beta; interface function genbet(x,y:real);C;
The result type is missing. Further, `float' in C is `Single' or `ShortReal' in Pascal. On some platforms, the difference to `Real' doesn't cause problems, but on others, it does. So better use:
function genbet(x,y:ShortReal):ShortReal;C;
implementation end.
Second, test.p: program betadev; uses beta; begin writeln(genbet(100,150)); end.
Finally, I compile it with gpc and the following message appears: "undefined first referenced symbol in file genbet /var/tmp/cciCa09s1.o ld: fatal: symbol referencing errors No output written to test collect2 : ld returned 1 exit status"
So... What is wrong?
You need to link the C code. For a simple C file, you can insert `{$L foo.c}' into the unit, and GPC will automatically compile the C file. For a library libbar.a, you can use `{$L bar}' in the source which is equivalent to `-lbar' on the command line.
Frank