\section{Conclusion}

In this paper, we presented solutions on coupling C++ or Java code with MATLAB,
utilizing the CTL. In addition to the manual approach, we provide two 
code-generators, one using MCC, the other one using MEX, which are able to
automate the coupling process, as well as all of our example code, both 
released under the terms of the LGPL.

All of the example code was built and tested on Linux 
(\input{/etc/arch-release}) with 
GCC 3.3.6, 
CTL4j version 0.9.7, 
CTL/C++ version 1.2 (with this patch applied:
	\url{https://shuya.ath.cx/~neocool/code/CTL/myCTL-20070204.diff}) and 
MATLAB version 7.2 .

The example code is available here: 
\url{https://shuya.ath.cx/~neocool/tmp/matlab/sample.tar.gz}.
Further development of the code generators happens inside the CTL4j SVN
repository:
\url{https://shuya.ath.cx/svn-legacy/ctl4j/}.
For any bug reports or feature requests contact \url{mailto:boris@icculus.org}.

\label{gcc}
\textbf{Important:} Make sure that your CTL/C++ was compiled with GCC 3.3.x and
that the \textbf{g++} in your PATH is also of the same version 3.3.x, otherwise
the linker will have two or more different \textbf{libstdc++} shared libraries
to choose from, which might lead to undefined runtime behaviour and all kinds
of weird things can happen. Even though GCC 3.3.x is the only supported
compiler, you may want to use a different one, using the following procedure:

\begin{verbatim}
cd $MATLAB
cd sys/os/glnx86
mkdir old
mv libstdc++.* libg2c.* libgcc_s* old
\end{verbatim}

Now you should copy the corresponding libraries of your gcc installation into the
directory \textit{sys/os/glnx86/} (\cite{MATLAB1}).

If your administrator did not install GCC 3.3.x or your distribution does not
provide it anymore, you can also compile it yourself very easily. First, get the
GCC tarball (gcc-3.3.6.tar.bz2) from your local GNU mirror, then use the following
commands to compile and install it in your home directory (~50MB of free diskspace
needed):

\begin{verbatim}
mkdir gcc-build &&
cd gcc-build &&
../gcc-3.3.6/configure --prefix=$HOME/software/gcc-3.3 --enable-shared \
	--enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit \
	--enable-clocale=gnu &&
make bootstrap &&
make install
\end{verbatim}

Now you can use that GCC instead of the system's one by putting 
\textit{\$HOME/software/gcc-3.3/bin} in front of your \textbf{PATH}.

The included code-generators provide a starting point for coupling larger
and more complex MATLAB projects and CTL components.

% vim: ft=tex
