Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10487 closed Bugs (fixed)

Multiple definitions of boost::numeric::odeint::detail::* by multiple #include

Reported by: guillaume.jacquenot@… Owned by: karsten
Milestone: Boost 1.57.0 Component: odeint
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc: guillaume.jacquenot@…

Description

Dear all,

I encountered a linker problem within the odeint code of library boost::numeric with boost 1.56 on Debian 32 bit with gcc 4.7. There (and I guess on many other compilers) will be multiple definitions of functions. The error is known not to occur with version 1.55.0.

When using several inclusions of the following files in various code file

#include <boost/numeric/odeint/stepper/euler.hpp> #include <boost/numeric/odeint/stepper/runge_kutta4.hpp> #include <boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp>

the linker produces an error of multiple definitions for boost::numeric::odeint::detail.

This linker problem will not occur if only one .cpp file #includes this file.

Possible explanation taken from bug number 7678:

Seemingly compiling each compile unit like foo.cpp, bar.cpp, etc. produces a definition into its individual .obj-file, namely foo.obj, bar.obj, etc.. Later the linker can not resolve which of the multiple definitions of "belongs", the one in foo.obj or the one in bar.obj, to take when binding the executable.

CMake log:

Linking CXX executable run_all_tests XXXXXXXXXXX/libXXXXXXXXXXX_static.a(FILE_YYYYYYYYYYYYY.cpp.o):(.bss+0x0): multiple definition of `boost::numeric::odeint::detail::_2' src/FILE_ZZZZZZZZZZZ.cpp.o:(.bss+0x10): first defined here XXXXXXXXXXX/libXXXXXXXXXXX_static.a(FILE_YYYYYYYYYYYYY.cpp.o):(.bss+0x1): multiple definition of `boost::numeric::odeint::detail::_1' src/FILE_ZZZZZZZZZZZ.cpp.o:(.bss+0x11): first defined here collect2: error: ld returned 1 exit status

The bug is similar to the one described here

https://svn.boost.org/trac/boost/ticket/7678

Guillaume Jacquenot

Change History (3)

comment:1 by guillaume.jacquenot@…, 8 years ago

Cc: guillaume.jacquenot@… added
Summary: Multiple definitions of bool boost::numeric::odeint by multiple #includeMultiple definitions of boost::numeric::odeint::detail::* by multiple #include

comment:2 by karsten, 8 years ago

Resolution: fixed
Status: newclosed

Already fixed in https://github.com/headmyshoulder/odeint-v2

The fix will apear in Boost 1.58.

comment:3 by telcom, 8 years ago

The same issue exists in Visual Studio 2012 C++11, Boost 1.56. Possible temporary solution is, getting odeint-v2 from gitub and replace the following folders and file in the include path of numeric: ~/numeric/odeint :: folder odeint.hpp :: file

Tested and verified.

Note: See TracTickets for help on using tickets.