\HeaderA{SHLIB}{Build Shared Object/DLL for Dynamic Loading}{SHLIB}
\keyword{utilities}{SHLIB}
\begin{Description}\relax
Compile the given source files and then link all specified object
files into a shared library aka DLL which can be loaded into \R{} using
\code{dyn.load} or \code{library.dynam}.
\end{Description}
\begin{Usage}
\begin{verbatim}
R CMD SHLIB [options] [-o dllname] files
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{files}] a list specifying the object files to be included in the
shared object/DLL.  You can also include the name of source files (for
which the object files are automagically made from their sources)
and library linking commands.

\item[\code{dllname}] the full name of the shared object/DLL to be built,
including the extension (typically \file{.so} on Unix systems, and
\file{.dll} on Windows).  If not given, the basename of the object
is taken from the basename of the first file.
\item[\code{options}] Further options to control the processing.  Use
\code{R CMD SHLIB --help} for a current list.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{R CMD SHLIB} is the mechanism used by \code{\LinkA{INSTALL}{INSTALL}} to
compile source code in packages.  It will generate suitable
compilation commands for C, C++, ObjC(++) and Fortran sources: Fortran
90/95 sources can also be used but it may not be possible to mix these
with other languages (on most platforms it is possible to mix with C,
but mixing with C++ rarely works).

Please consult section \sQuote{Creating shared objects} in the manual
\sQuote{Writing R Extensions} for how to customize it (for example to
add \code{cpp} flags and to add libraries to the link step) and for
details of some of its quirks.

Items in \code{files} with extensions \file{.c}, \file{.cpp},
\file{.cc}, \file{.C}, \file{.f}, \file{.f90}, \file{.f95}, \file{.m}
(ObjC), \file{.M} and \file{.mm} (ObjC++) are regarded as source
files, and those with extension \file{.o} as object files.  All other
items are passed to the linker.

Option \option{-n} (also known as \option{--dry-run}) will show the
commands that would be run without actually executing them.
\end{Details}
\begin{Note}\relax
Some binary distributions of \R{} have \code{SHLIB} in a separate
bundle, e.g., an \code{R-devel} RPM.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{COMPILE}{COMPILE}},
\code{\LinkA{dyn.load}{dyn.load}},
\code{\LinkA{library.dynam}{library.dynam}}.

The section on \dQuote{Customizing compilation} in the \dQuote{R
Administration and Installation} manual (see the \file{doc/manual}
subdirectory of the \R{} source tree).

The \sQuote{R Installation and Administration} and \sQuote{Writing R 
Extensions} manuals.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}## Not run: 
R CMD SHLIB -o mylib.so a.f b.f -L/opt/acml3.5.0/gnu64/lib -lacml
## End(Not run)\end{ExampleCode}
\end{Examples}

