/usr/share/doc/libcnf-dev/html/node44.html is in libcnf-dev 4.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Compiling and Linking</TITLE>
<META NAME="description" CONTENT="Compiling and Linking">
<META NAME="keywords" CONTENT="sun209">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="sun209.css">
<LINK REL="next" HREF="node45.html">
<LINK REL="previous" HREF="node43.html">
<LINK REL="up" HREF="sun209.html">
<LINK REL="next" HREF="node45.html">
</HEAD>
<BODY >
<BR> <HR>
<A NAME="tex2html656"
HREF="node45.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html654"
HREF="sun209.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html648"
HREF="node43.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> <A HREF="sun209.html#stardoccontents"><IMG
ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html657"
HREF="node45.html">Implementation Specific Details</A>
<BR>
<B>Up:</B> <A NAME="tex2html655"
HREF="sun209.html">CNF and F77 Mixed Language Programming - FORTRAN and C</A>
<BR>
<B> Previous:</B> <A NAME="tex2html649"
HREF="node43.html">Other Approaches to Mixed Language Programming</A>
<BR> <HR> <P>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000140000000000000000"></A><A NAME="xref_compiling_and_linking"></A><A NAME="compiling_and_linking"></A>
<BR>
Compiling and Linking
</H1>
<P>
Unless they are passing pointers to subprograms, FORTRAN programs do not need
to be compiled in any special way when employing mixed language programming
since they are not aware that the subprogram that they are calling is not
written in FORTRAN. However, when pointers are passed using the mechanism
described in
<A HREF="node34.html#percentval">Accessing Dynamic Memory from C and
FORTRAN</A>,
the FORTRAN code must include the statement:
<BLOCKQUOTE><PRE>
INCLUDE 'CNF_PAR'
</PRE></BLOCKQUOTE>
to define the function <TT>CNF_PVAL</TT>.
<P>
Type:
<BLOCKQUOTE><PRE>
% cnf_dev
</PRE></BLOCKQUOTE>
to define the link, <TT>CNF_PAR</TT>, to the required include file.
<P>
When compiling a C function that is
to be called from FORTRAN, it should contain the line:
<P>
<BLOCKQUOTE>
<TT>#include "f77.h"</TT>
</BLOCKQUOTE>
<P>
to define the F77 macros and CNF functions<A NAME="tex2html7"
HREF="footnode.html#foot2048"><SUP>2</SUP></A>.
<P>
On a Unix system, you can usually tell the C compiler where to look for
header files with the <TT>-I</TT> qualifier to the cc command,
<I>e.g.</I>:
<P>
<BLOCKQUOTE><PRE>
% cc -I/star/include -c func.c
</PRE></BLOCKQUOTE>
<P>
All FORTRAN <TT>INCLUDE</TT> and C header files for Starlink software are
stored in the directory <TT>/star/include</TT>, and the object files for all
Starlink libraries reside in <TT>/star/lib</TT>.
<P>
To link a FORTRAN program <TT>prog.f</TT> and a C function <TT>sub.c</TT> with
the CNF library, first compile the C function and then compile and link the
FORTRAN program:
<P>
<BLOCKQUOTE> <PRE>
% cc -c -I/star/include sub.c
% f77 prog.f sub.o -L/star/lib `cnf_link` -o prog
</PRE> </BLOCKQUOTE>
<P>
To link a C program <TT>prog.c</TT> with a FORTRAN subroutine <TT>sub.f</TT>,
the procedure varies depending upon the system being used.
It is usually best to try to do the link with the <TT>f77</TT> command as the
correct FORTRAN libraries will then be searched.
However, in some cases there is confusion over the main routine and either
<TT>cc</TT> or <TT>ld</TT> must be used specifying all the required libraries.
<P>
For example, on Alpha/OSF1 it might be:
<P>
<BLOCKQUOTE> <PRE>
% f77 -c sub.f
% cc prog.c sub.o -L/star/lib `cnf_link` -lfor -lots -o prog
</PRE> </BLOCKQUOTE>
<P>
For
<A HREF="/star/docs/sg4.htx/sg4.html#xref_">ADAM</A>
tasks, much of the complication is removed by the task
linking scripts
<A HREF="/star/docs/sun144.htx/sun144.html#xref_ADAM_link_scripts">alink and ilink</A> which will accept a mixture of
FORTRAN and C modules to compile. For example:
<BLOCKQUOTE><PRE>
% alink task.f subr.c ...
</PRE></BLOCKQUOTE>
or
<BLOCKQUOTE><PRE>
% alink task.c subr.f ...
</PRE></BLOCKQUOTE>
The CNF library will be linked automatically and <TT>/star/include</TT> searched
for any required C header files.
<P>
The first program module specified for the ADAM link script must be the main
routine of the ADAM task, which is written as a FORTRAN subroutine or C function
with a single <TT>INTEGER</TT>, or <TT>int *</TT>, argument (see
<A HREF="/star/docs/sun144.htx/sun144.html#xref_ADAM_link_scripts">SUN/144</A>
for details).
<P>
<P>
<BR> <HR>
<A NAME="tex2html656"
HREF="node45.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html654"
HREF="sun209.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html648"
HREF="node43.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> <A HREF="sun209.html#stardoccontents"><IMG
ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html657"
HREF="node45.html">Implementation Specific Details</A>
<BR>
<B>Up:</B> <A NAME="tex2html655"
HREF="sun209.html">CNF and F77 Mixed Language Programming - FORTRAN and C</A>
<BR>
<B> Previous:</B> <A NAME="tex2html649"
HREF="node43.html">Other Approaches to Mixed Language Programming</A>
<BR> <HR> <P>
<!--End of Navigation Panel-->
<ADDRESS>
<I>CNF and F77 Mixed Language Programming -- FORTRAN and C<BR>Starlink User Note 209<BR>P.M. Allan<BR>A.J. Chipperfield<BR>R.F. Warren-Smith<BR>19 January 2000<BR>E-mail:<A HREF="mailto:ussc@star.rl.ac.uk">ussc@star.rl.ac.uk</A></I>
</ADDRESS>
</BODY>
</HTML>
|