[clean-list] Linking Clean to DISLIN

Siegfried Gonzi siegfried.gonzi@stud.uni-graz.at
Sat, 03 May 2003 15:40:33 +0200


Lets assume I have a plotting library DISLIN which lets me use it as
follows:

[exa_c.c for example has the DISLIN header file: #include "dislin.h"]

gcc -o exa_c exa_c.o -L$DISLIN -ldislnc -lm

creates ./exa_c

According to the DISLIN manual the -L option can be omitted if links to
the DISLIN libraries are created in /usr/lib (note my dislin libraries
reside in: /usr/local/dislin)

ln -s $DISLIN/lib/dislin-7.6.so libdislin.so.7
ln -s libdislin.so.7            libdislin.so

ln -s $DISLIN/lib/dislnc-7.6.so  libdislnc.so.7
ln -s libdislnc.so.7              libdislnc.so

ln -s $DISLIN/lib/dislin-7.6.a    libdislin.a
ln -s $DISLIN/lib/dislnc-7.6.a    libdislnc.a

I wrote the above because I do not have any clue, but a C expert should
easily discern what my post is about.

I think I have a basic understanding of including C functions in Clean
(see also my post the other day:  
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&group=comp.lang.functional&selm=3EB1FCEB.5070408%40kfunigraz.ac.at)

But I am a bit baffled now because the header functions of DISLIN expect
float-pointers. I am not sure how to circumvent this but with wrapper
functions:

test_plot_c.c
==
#include <stdio.h>
#include <math.h>
// dislin
#include <dislin.h>

void clean_qplot (double *xray, double *yray, int n)
{
	qplot(&xray[0], &yray[0], n);
}
==

After making the object file (gcc -o test_plot_c.c) I get the warning
message that qplot expects float pointers, but this was my first try and
I do not know whether they become automatically coerced when passing
double-pointers from Clean to float-pointers in C. The original DISLIN
function is:

void qplot(float *xray,float *yray,int n);

But this is not the problem (yet) I have no clue how to link the
aforementioned object file with DISLIN and test_plot_main.icl alike?:

clm -l test_plot_c.o -ldislnc test_plot_main

does not work [note: linking an ordinary C program with DISLIN is as
follows: gcc -o exa_c exa_c.o -L$DISLIN -ldislnc -lm]

I am not sure whether it is possible to create a /linked/ test_plot_c.o
in advance? Is it possible to make test_plot_c.o which already has
DISLIN linked and passing this then on to:

clm -l test_plot_c.o test_plot_main

And how to pass floating-point vectors to a C-function? I mean DISLIN has 
570 header functions which expects mostly float values. I wrote a DISLIN binding 
for Bigloo (Scheme) and could use floating-point values. 
One way would be to copy around things, but this is cumbersome:

1) my_malloc in a Clean program
2) copying a Clean list to my_malloc
3) passing this my_malloc to a DISLIN C wrapper function
4) before the wrapper function is going to forward the passed pointer to a
   native DISLIN function it becomes again converted to a float-pointer: 
(double *p) -> (float *p) 

DISLIN (www.dislin.de) is a high quality plotting library for Python, 
Perl, Java, C, Fortran 77, Fortran 90 and my inofficial (not released yet)
binding to Bigloo (Scheme).

My super computing farm: SuSE 8 Linux, Clean 2.02

Regards,
S. Gonzi