From: Frank Heckenbach frank@g-n-u.de To: gpc@gnu.de Subject: Re: beta distribution Date: Wed, 5 Jul 2000 13:22:37 +0200
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.
I am not sure to understand. Do I have to put {$L randlib.c} in beta.p
like
this:
If you have a self-contained file randlib.c. If randlib.c requires other C files, say baz.c, add `{$L baz.c}' as well. However, if you have librandlib.a instead, read on.
unit beta; interface {$L randlib.c} function genbet(x,y:shortreal):shortreal;C; implementation end.
and keep my program called 'test' like this:
program betadev; uses beta; begin writeln(genbet(100,150)); end.
and after if I compile the first one, the following message appears: beta.p:5: file `randlib.c' not found
and for the second one: Undefined first referenced symbol in file genbet /var/tmp/cc5OaGYv1.o ld: fatal: Symbol referencing errors. No output written to test collect2: ld returned 1 exit status
When you say "For a library libbar.a, you can use `{$L bar}' in the
source
which is equivalent to `-lbar' on the command line.", what is the source
in
this case?
GPC doesn't care. For libraries, it expects them to be compiled already. I.e., if you have librandlib.a (a compiled library), add `{$L randlib}' in the Pascal source.
If you have the sources for librandlib, compile them first (according to the (hopefully) accompanying instructions), to get librandlib.a (or librandlib.so, a shared library, which can also be used by `{$L randlib}').
So I will try to summurize all steps I made before still trying to be understood... At first, I have downloaded randlibc-1.3.tar.gz. After having unpacked this file, a randlib.c directory was created and it contains: HOWTOGET* README* doc/ src/ test/
I have received help from Maurice Lombardi to install this randlib routines: ------------------------------------------------------------------
From: Maurice Lombardi Maurice.Lombardi@ujf-grenoble.fr To: Nathalie Jarosz jarosz_n@hotmail.com CC: gpc@gnu.de Subject: Re: beta distribution Date: Fri, 30 Jun 2000 16:24:07 +0200
Have you read these two text files and those contained in the doc folder
?
Usually they contain instructions on whet do do to install the package.
Yes of course but nothing clear to me:
INSTALLATION
Directory src contains the C source for most of the routines. The files com.c and randlib.c constitute RANDLIB. The file randlib.h contains prototypes for the RANDLIB routines that should be used (and not for a few internal routines). The C code from these directories should be compiled and placed in a library. Directory test contains three test programs for this code. The file randlib.h in directory test is a copy of that in src.
Where have you gotten randlibc-1.3.tar.gz from ?
I get from: http://odin.mdacc.tmc.edu/anonftp/page_2.html#RANDLIB
Well it is simple enough to be made by hand (there are no dependencies). With GNU tools type:
cd src gcc -c -O2 com.c gcc -c -O2 linpack.c gcc -c -O2 randlib.c # ^uppercase: meand Optimize # at this point you have created com.o linpack.o randlib.o # to put them in a library librandlib.a type: ar -rv librandlib.a com.o linpack.o randlib.o ranlib librandlib.a # ^ no d: it is a system function
#then move librandlib.a into a system wide library directory e.g. /usr/local/lib # randlib.h include /usr/local/include
#to check the result cd ../test gcc -O2 -o tstbot tstbot.c -lrandlib ^lowercase: means output ./tstbot
#etc..." ----------------------------------------------------------------------- So I did all this but I still don't understand how to use the famous betadev function I would like to use in a pascal program and which is in these randlib routines written in C...
Thanks in advance for your help,
Nathalie
________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com