
* 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. --- milena/ChangeLog | 14 +++++ milena/doc/examples/multi_files_f1.cc.raw | 6 ++ milena/doc/examples/multi_files_f2.cc.raw | 6 ++ milena/doc/examples/multi_files_main.cc.raw | 16 ++++++ milena/doc/examples/multiple_def.cc.raw | 9 +++ milena/doc/examples/typenametemplate.cc.raw | 1 + milena/doc/examples/undef_global_vars.cc.raw | 1 + milena/doc/examples/wrongvaluetype.cc.raw | 2 + milena/doc/ref-guide.tex | 69 +++++++++++++++++++++----- 9 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 milena/doc/examples/multi_files_f1.cc.raw create mode 100644 milena/doc/examples/multi_files_f2.cc.raw create mode 100644 milena/doc/examples/multi_files_main.cc.raw create mode 100644 milena/doc/examples/multiple_def.cc.raw create mode 100644 milena/doc/examples/typenametemplate.cc.raw create mode 100644 milena/doc/examples/undef_global_vars.cc.raw create mode 100644 milena/doc/examples/wrongvaluetype.cc.raw diff --git a/milena/ChangeLog b/milena/ChangeLog index 17521bf..76aef9a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,19 @@ 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> + * doc/Doxyfile.in: Expand more macros. 2013-04-17 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/milena/doc/examples/multi_files_f1.cc.raw b/milena/doc/examples/multi_files_f1.cc.raw new file mode 100644 index 0000000..57e17bd --- /dev/null +++ b/milena/doc/examples/multi_files_f1.cc.raw @@ -0,0 +1,6 @@ +#include <mln/core/image/image2d.hh> + +void f1() +{ + +} diff --git a/milena/doc/examples/multi_files_f2.cc.raw b/milena/doc/examples/multi_files_f2.cc.raw new file mode 100644 index 0000000..730ae3f --- /dev/null +++ b/milena/doc/examples/multi_files_f2.cc.raw @@ -0,0 +1,6 @@ +#include <mln/core/image/image2d.hh> + +void f2() +{ + +} diff --git a/milena/doc/examples/multi_files_main.cc.raw b/milena/doc/examples/multi_files_main.cc.raw new file mode 100644 index 0000000..f131099 --- /dev/null +++ b/milena/doc/examples/multi_files_main.cc.raw @@ -0,0 +1,16 @@ +#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(); +} diff --git a/milena/doc/examples/multiple_def.cc.raw b/milena/doc/examples/multiple_def.cc.raw new file mode 100644 index 0000000..741273c --- /dev/null +++ b/milena/doc/examples/multiple_def.cc.raw @@ -0,0 +1,9 @@ +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 diff --git a/milena/doc/examples/typenametemplate.cc.raw b/milena/doc/examples/typenametemplate.cc.raw new file mode 100644 index 0000000..4ec2d50 --- /dev/null +++ b/milena/doc/examples/typenametemplate.cc.raw @@ -0,0 +1 @@ +error: using 'typename' outside of template \ No newline at end of file diff --git a/milena/doc/examples/undef_global_vars.cc.raw b/milena/doc/examples/undef_global_vars.cc.raw new file mode 100644 index 0000000..92c506f --- /dev/null +++ b/milena/doc/examples/undef_global_vars.cc.raw @@ -0,0 +1 @@ +#undef MLN_WO_GLOBAL_VARS diff --git a/milena/doc/examples/wrongvaluetype.cc.raw b/milena/doc/examples/wrongvaluetype.cc.raw new file mode 100644 index 0000000..7ed1a68 --- /dev/null +++ b/milena/doc/examples/wrongvaluetype.cc.raw @@ -0,0 +1,2 @@ +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 diff --git a/milena/doc/ref-guide.tex b/milena/doc/ref-guide.tex index 6e4a790..b26929a 100644 --- a/milena/doc/ref-guide.tex +++ b/milena/doc/ref-guide.tex @@ -245,21 +245,60 @@ Olena's tarball is structured as follow: Before writing your first program, please be aware of these hints: \begin{itemize} - \item By default, Olena enables a lot of internal pre and post conditions. - Usually, this is a useful feature and it \should be enabled. However, it can heavily - slow down a program though so these tests can be disabled by compiling - using \code{-DNDEBUG}. + \item By default, Olena enables a lot of internal pre and post + conditions. Usually, this is a useful feature and it \should be + enabled. However, it can heavily slow down a program though so + these tests can be disabled by compiling using \code{-DNDEBUG}. \begin{verbatim} -$ g++ -DNDEBUG -Ipath/to/mln my_program.cc +$ g++ -O2 -DNDEBUG -Ipath/to/mln my_program.cc \end{verbatim} %$ - \item If you decide to use optimization flags to compile for debugging, - prefer using \code{-O1}. It is much faster to compile and it gives good - performance results. + \item If you decide to use optimization flags to compile for + debugging, prefer using \code{-O1}. It is much faster to compile + 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} +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 @@ -721,7 +760,7 @@ Note that: %================================================ -%\doxysection{imamorphed}{Morphed images} +\doxysection{imamorphed}{Morphed images} %//FIXME: Write it! %// Pas concrete, light, how to concrete % @@ -1990,8 +2029,7 @@ In this section, the most common compilation errors are gathered and explained. \begin{itemize} \item - \textbf{error: 'check' is not a member of 'mln::metal::not\_equal$<$bool, bool$>$} \\ - \textbf{error: 'check' is not a member of 'mln::metal::converts\_to$<$mln::value::rgb$<$8u$>$, unsigned int$>$'} \\ + \doxyrawcode{wrongvaluetype} The routine does not support a given image with such a value type 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. \item - \textbf{error: using 'typename' outside of template} \\ + \doxyrawcode{typenametemplate} Macros like \code{mln\_site} or \code{mln\_domain} can only be used in templated functions. In order to use them in a non-templated function, a `\_' must be appended to the macro 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} -- 1.7.2.5