
\section[FAQs]{FAQs}
\label{sec:faqs}
\addcontentsline{toc}{section}{\thesection. FAQs}


\subsection[ZeroMQ Errors]{ZeroMQ Errors}
\label{sec:zmq_errors}
\addcontentsline{toc}{subsection}{\thesubsection. ZeroMQ Errors}


\begin{enumerate}
\item {\bf\color{blue} Q:}
      If the package installs successfully, but fails at initialization with
\begin{Error}
error: unable to load shared object
'/Users/your_username/Library/R/3.2/library/pbdZMQ/libs/pbdZMQ.so':

dlopen(/.../R/3.2/library/pbdZMQ/libs/pbdZMQ.so, 6):
Library not loaded: /.../src/zmq/lib/libzmq.4.dylib

Referenced from: /.../R/3.2/library/pbdZMQ/libs/pbdZMQ.so
\end{Error}
or
\begin{Error}
Library not loaded: /usr/lib/libzmq.4.dylib
\end{Error}
or
\begin{Error}
Library not loaded: /usr/lib/libzmq.so.4.0.0
\end{Error}
      {\bf\color{blue} A:}
      From the ZeroMQ installation messages:
\begin{Code}
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
\end{Code}
    Further, for Mac OSX, the \code{otool} and \code{install_name_tool}
    commands are able to find and modify the linking path of \code{pbdZMQ.so}
    to the library \code{libzmq.4.dylib}.
    See the source of
    \code{pbdZMQ/src/install.libs.R} for how to change the linking path,
    accordingly. The basic steps are:
    \begin{enumerate}
    \item to use \code{otool -L pbdZMQ.so} to figure which
          \code{libzmq.4.dylib} is linked. Note that \code{pbdZMQ.so}
          should be the one in the installed directory, e.g. \\
          \code{/your_R_library_root_path/library/pbdZMQ/libs/pbdZMQ.so},
          and
    \item to use \code{install_name_tool -change org_dylib new_dylib pbdZMQ.so}
          to update to the right \code{new_dylib}, e.g. \\
          \code{/your_R_library_root_path/library/pbdZMQ/libs/libzmq.4.dylib}.
    \end{enumerate}
    For linux/unix, the \code{readelf}, \code{chrpath}, \code{pathelf},
    \code{ld.so}, and \code{/etc/ld.so.conf} (depending on systems and
    compilers) may serve the same roles as the \code{otool} and
    \code{install_name_tool} in Mac OSX.
\end{enumerate}




\subsection[ZeroMQ Flags]{ZeroMQ Flags}
\label{sec:zmq_flags}
\addcontentsline{toc}{subsection}{\thesubsection. ZeroMQ Flags}


\begin{enumerate}
\item {\bf\color{blue} Q:}
      How do I compile and link with ZeroMQ via \pkg{pbdZMQ} for my package
      which has \proglang{C/C++} code that call ZeroMQ functions?
      {\bf\color{blue} A:}
      There are two \pkg{pbdZMQ} functions: \code{get.zmq.cppflags()} and
      \code{get.zmq.ldflags()} that provide flags for compiling
      with ZMQ header files and linking against \code{libzmq.so} or
      \code{libzmq.dll}, respectivelly.
      Typically, these two functions will be envoked inside \code{Makevars}
      and \code{Makevars.win} via \code{Rscript -e '...'} to return the flags
      and append to whereever they are needed.

\end{enumerate}

