Commit 9df9980f authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add explanations on compilation with multiple files.

	* doc/examples/multi_files_f1.cc.raw,
	* doc/examples/multi_files_f2.cc.raw,
	* doc/examples/multi_files_main.cc.raw,
	* doc/examples/multiple_def.cc.raw,
	* doc/examples/typenametemplate.cc.raw,
	* doc/examples/undef_global_vars.cc.raw,
	* doc/examples/wrongvaluetype.cc.raw: New.

	* doc/ref-guide.tex: Add a new section.
parent 002e0e95
2013-04-17 Guillaume Lazzara <z@lrde.epita.fr>
Add explanations on compilation with multiple files.
* doc/examples/multi_files_f1.cc.raw,
* doc/examples/multi_files_f2.cc.raw,
* doc/examples/multi_files_main.cc.raw,
* doc/examples/multiple_def.cc.raw,
* doc/examples/typenametemplate.cc.raw,
* doc/examples/undef_global_vars.cc.raw,
* doc/examples/wrongvaluetype.cc.raw: New.
* doc/ref-guide.tex: Add a new section.
2013-04-17 Guillaume Lazzara <z@lrde.epita.fr> 2013-04-17 Guillaume Lazzara <z@lrde.epita.fr>
   
* doc/Doxyfile.in: Expand more macros. * doc/Doxyfile.in: Expand more macros.
#include <mln/core/image/image2d.hh>
void f1()
{
}
#include <mln/core/image/image2d.hh>
void f2()
{
}
#undef MLN_WO_GLOBAL_VARS
// This include is needed here to compile the global variables with
// this file. We include that file because it is used in other parts
// of the project.
#include <mln/core/image/image2d.hh>
// Forward declarations
void f1();
void f2();
int main()
{
f1();
f2();
}
fidji\% g++ main.cc f1.cc f2.cc -I$OLN/milena
/tmp/ccZLOEyG.o:(.data+0x0): multiple definition of `mln::debug::trace::quiet'
/tmp/ccqHhSP3.o:(.data+0x0): first defined here
/tmp/ccZLOEyG.o:(.bss+0x0): multiple definition of `mln::debug::trace::tab'
/tmp/ccqHhSP3.o:(.bss+0x0): first defined here
/tmp/ccZLOEyG.o:(.bss+0x4): multiple definition of `mln::debug::trace::full_trace'
/tmp/ccqHhSP3.o:(.bss+0x4): first defined here
/tmp/ccZLOEyG.o:(.bss+0x20): multiple definition of `mln::debug::trace::start_times_'
/tmp/ccqHhSP3.o:(.bss+0x20): first defined here
error: using 'typename' outside of template
\ No newline at end of file
error: 'check' is not a member of 'mln::metal::not_equal<bool, bool>}
error: 'check' is not a member of 'mln::metal::converts_to<mln::value::rgb<8u>, unsigned int>'
\ No newline at end of file
...@@ -245,21 +245,60 @@ Olena's tarball is structured as follow: ...@@ -245,21 +245,60 @@ Olena's tarball is structured as follow:
Before writing your first program, please be aware of these hints: Before writing your first program, please be aware of these hints:
\begin{itemize} \begin{itemize}
\item By default, Olena enables a lot of internal pre and post conditions. \item By default, Olena enables a lot of internal pre and post
Usually, this is a useful feature and it \should be enabled. However, it can heavily conditions. Usually, this is a useful feature and it \should be
slow down a program though so these tests can be disabled by compiling enabled. However, it can heavily slow down a program though so
using \code{-DNDEBUG}. these tests can be disabled by compiling using \code{-DNDEBUG}.
\begin{verbatim} \begin{verbatim}
$ g++ -DNDEBUG -Ipath/to/mln my_program.cc $ g++ -O2 -DNDEBUG -Ipath/to/mln my_program.cc
\end{verbatim} \end{verbatim}
%$ %$
\item If you decide to use optimization flags to compile for debugging, \item If you decide to use optimization flags to compile for
prefer using \code{-O1}. It is much faster to compile and it gives good debugging, prefer using \code{-O1}. It is much faster to compile
performance results. and it gives good performance results.
\end{itemize}
\doxysection{multicompile}{Compiling a multiple files program with Olena}
In case of a large project, Olena may be used in several source
files. Even if compilation is fine, you may encounter the following
linking error:
\doxyrawcode{multiple_def}
These multiple symbol definitions are due to some global variables
used in Olena. They are built in each source file which includes Olena
headers and are therefore duplicated, causing linking errors.
An easy way to override this issue is to compile all the source files
of your project passing -DMLN\_WO\_GLOBAL\_VARS.
Then, at the top of one of the files which includes Olena headers, add:
\doxyrawcode{undef_global_vars}
Here is a small example.
\begin{itemize}
\item main.cc
\doxyrawcode{multi_files_main}
\item f1.cc
\doxyrawcode{multi_files_f1}
\item f2.cc
\doxyrawcode{multi_files_f2}
\end{itemize} \end{itemize}
This example can be compiled with the following command:
\begin{verbatim}
$ g++ -DNDEBUG -O2 -DMLN_WO_GLOBAL_VARS -Ipath/to/mln main.cc f1.cc f2.cc
\end{verbatim}
%$
Note that the file where MLN\_WO\_GLOBAL\_VARS is undefined must
include olena headers to declare and compile the global variables.
%==================================== %====================================
%\clearpage %\clearpage
...@@ -721,7 +760,7 @@ Note that: ...@@ -721,7 +760,7 @@ Note that:
%================================================ %================================================
%\doxysection{imamorphed}{Morphed images} \doxysection{imamorphed}{Morphed images}
%//FIXME: Write it! %//FIXME: Write it!
%// Pas concrete, light, how to concrete %// Pas concrete, light, how to concrete
% %
...@@ -1990,8 +2029,7 @@ In this section, the most common compilation errors are gathered and explained. ...@@ -1990,8 +2029,7 @@ In this section, the most common compilation errors are gathered and explained.
\begin{itemize} \begin{itemize}
\item \item
\textbf{error: 'check' is not a member of 'mln::metal::not\_equal$<$bool, bool$>$} \\ \doxyrawcode{wrongvaluetype}
\textbf{error: 'check' is not a member of 'mln::metal::converts\_to$<$mln::value::rgb$<$8u$>$, unsigned int$>$'} \\
The routine does not support a given image with such a value type The routine does not support a given image with such a value type
or an automatic conversion from the image value type to the or an automatic conversion from the image value type to the
...@@ -1999,13 +2037,20 @@ In this section, the most common compilation errors are gathered and explained. ...@@ -1999,13 +2037,20 @@ In this section, the most common compilation errors are gathered and explained.
\item \item
\textbf{error: using 'typename' outside of template} \\ \doxyrawcode{typenametemplate}
Macros like \code{mln\_site} or \code{mln\_domain} can only be Macros like \code{mln\_site} or \code{mln\_domain} can only be
used in templated functions. In order to use them in a used in templated functions. In order to use them in a
non-templated function, a `\_' must be appended to the macro non-templated function, a `\_' must be appended to the macro
name. For instance : \code{mln\_site\_} and \code{mln\_domain\_}. name. For instance : \code{mln\_site\_} and \code{mln\_domain\_}.
\item
\doxyrawcode{multiple_def}
This is because, by default, Milena does not support compilation
with multiple .cc files. Section \doxyref{multicompile} describes
how to do that.
\end{itemize} \end{itemize}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment