Building sharable object libraries for CALL_EXTERNAL [message #14591] |
Fri, 12 March 1999 00:00  |
Octavi Fors
Messages: 13 Registered: March 1999
|
Junior Member |
|
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hello,
<p>This is my first trial calling a C-routine from IDL with CALL_EXTERNAL,
and I have some problems with building <i>routine.so</i> file. It's just
a test, so the routine it's very simple:
<p><font size=-1>#include <math.h></font>
<br><font size=-1>#include <stdio.h></font>
<br><font size=-1>#include <stdlib.h></font>
<br><font size=-1>#include <fcntl.h></font>
<br><font size=-1>#include <sys/types.h></font>
<br><font size=-1>#include <sys/stat.h></font>
<br><font size=-1>#include <string.h></font><font size=-1></font>
<p><font size=-1>float** routine(argc,argv)</font>
<br><font size=-1>int argc;</font>
<br><font size=-1>void *argv[];</font>
<br><font size=-1>{</font>
<br><font size=-1>int n, x, y;</font>
<br><font size=-1>float *input;</font>
<br><font size=-1>float **output;</font>
<br><font size=-1>int i,j;</font><font size=-1></font>
<p><font size=-1> input = (float *) argv[0];</font>
<br><font size=-1> n=*(int *) argv[1];</font>
<br><font size=-1> x=*(int *) argv[2];</font>
<br><font size=-1> y=*(int *) argv[3];</font><font size=-1></font>
<p><font size=-1> output=(float **)malloc(4*n);</font>
<br><font size=-1> for(i=0;i<n;i++) output[i]=(float*)malloc(4*x*y);</font><font size=-1></font>
<p><font size=-1>for(j=0;j<n;++j)</font>
<br><font size=-1>for(i=0;i<x*y;++i)</font>
<br><font size=-1>output[j][i]=input[i];</font><font size=-1></font>
<p><font size=-1>return(output);</font>
<br><font size=-1>}</font>
<p>First, I try to create routine.o with:
<br><font size=-1>$ cc -pic -fsingle -c routine.c</font>
<br>no problem.
<p>Second, when I try to create routine.so with:
<br><font size=-1>$ ld -o routine.so -z text routine.o (changing '-assert
pure-text' to '-z text' because it's a SunOS Version 5.5.1)</font>
<br><font size=-1> Undefined & amp;nbsp; & amp;nbsp; & amp;nbsp;
first referenced</font>
<br><font size=-1> symbol & ;nbsp; & ;nbsp; & ;nbsp; & ;nbsp;
in file</font>
<br><font size=-1> malloc & ;nbsp; & ;nbsp; & ;nbsp; & ;nbsp;
routine.o (symbol belongs to implicit dependency /usr/lib/libc.so.1)</font>
<br><font size=-1> .mul &n bsp; &n bsp; &n bsp; &n bsp; &n bsp;
routine.o (symbol belongs to implicit dependency /usr/lib/libc.so.1)</font>
<br><font size=-1> mcount & ;nbsp; & ;nbsp; & ;nbsp; & ;nbsp;
routine.o</font>
<br><font size=-1>ld: fatal: Symbol referencing errors. No output written
to routine.so</font><font size=-1></font>
<p>It seems to need /usr/lib/libc.so.1. So I add it in the command line:
<br><font size=-1>$ ld -o routine.so -z text routine.o /usr/lib/libc.so.1</font>
<br><font size=-1> Undefined & amp;nbsp; & amp;nbsp; & amp;nbsp;
first referenced</font>
<br><font size=-1> symbol & ;nbsp; & ;nbsp; & ;nbsp; & ;nbsp;
in file</font>
<br><font size=-1> mcount & ;nbsp; & ;nbsp; & ;nbsp; & ;nbsp;
routine.o</font>
<br><font size=-1>ld: fatal: Symbol referencing errors. No output written
to routine.so</font><font size=-1></font>
<p>Malloc error is gone, but mcount (?) remains. Does anybody know what's
wrong with it?
<p>Thans in advance,
<p>Octavi.
<pre>--
============================================================ =====
Octavi Fors Aldrich
Astronomy Department</pre>
<pre>Physics Faculty</pre>
<pre>Avgda. Diagonal 647
08028 Barcelona
SPAIN
Telf: 34-934021122
Fax: 34-934021133
e-mail: octavi@fajnm1.am.ub.es
============================================================ ===== </pre>
</html>
|
|
|