Opened 13 years ago

Closed 13 years ago

#3501 closed Bugs (fixed)

Reusing concepts from different compile units yields multiple defined symbols

Reported by: christoph.heindl@… Owned by: Gunter
Milestone: Boost 1.41.0 Component: uBLAS
Version: Boost 1.39.0 Severity: Problem
Keywords: Cc:

Description

Currently I use the ublas concepts defined in ublas/detail/concepts.hpp to derive concepts based on ublas concepts such as

template<class X> struct Vector : boost::numeric::ublas::VectorConcept<X> {};

In my unit test project I have different compile units that use BOOST_CONCEPT_ASSERT to assure Vector concept compliance. This yields multiple defined symbols for the following methods (and full specialized versions):

ublas/detail/concepts.hpp: void concept_checks(); template<class T> ZeroElement(T); template<class T> OneElement(T);

inlining those solves the problem (for me). I'm compiling on MSVC9.0. Current trunk seems to have this methods still not-inlined.

Change History (11)

comment:1 by Gunter, 13 years ago

(In [56578]) see #3501: Reusing concepts from different compile units yields multiple defined symbols

  • added BOOST_UBLAS_INLINE macros to requested locations

comment:2 by Gunter, 13 years ago

Status: newassigned

@Christoph: please check if the committed version fixes your problem. If not, please provide a small example to reproduce the problem.

comment:3 by anonymous, 13 years ago

@Gunter Committed version fixes my problem. I did not test on a fresh trunk checkout. All I did was replacing concepts.hpp of 1.39.0 by current head revision. Thanks for your help.

comment:4 by Gunter, 13 years ago

Resolution: fixed
Status: assignedclosed

(In [56614]) fix #3499 and fix #3501:

  • added inline to free helper functions
  • added missing concept check
  • fixed broken internal checks

comment:5 by christoph.heindl@…, 13 years ago

Resolution: fixed
Status: closedreopened

Hi Gunter,

I fear we need to reopen the bug. In Debug the same linker error as reported occurs because BOOST_UBLAS_INLINE is not defined to inline at all.

Therefore I suggest attributing the free functions with inline explicitely, unless someone knows a better solution.

best regards, Christoph

comment:6 by anonymous, 13 years ago

In config.hpp you can find the lines

#ifdef NDEBUG

#ifndef BOOST_UBLAS_INLINE
#define BOOST_UBLAS_INLINE inline
#endif
...

This means that inline is disabled in debug builds in order to be able to follow the execution path. Explicitely defining

#define BOOST_UBLAS_INLINE inline

before including any uBLAS header should solve the problem.

comment:7 by christoph.heindl@…, 13 years ago

It would solve the problem indeed.

I wonder, however, if requiring the user to do the bugfixing for a third-party library in his code is the best way to handle this.

comment:8 by Gunter, 13 years ago

(In [57202]) see #3501: Reusing concepts from different compile units yields multiple defined symbols (Incomplete)

  • removed inlines that were added with the last commit
  • added anonymous namespace to make functions local to compilation unit

comment:9 by Gunter, 13 years ago

(In [57208]) see #3501: Reusing concepts from different compile units yields multiple defined symbols (Incomplete)

  • updated documentation

comment:10 by Gunter, 13 years ago

(In [61114]) see #3501: moved release note entry to correct release

comment:11 by Gunter, 13 years ago

Resolution: fixed
Status: reopenedclosed

(In [61115]) fix #3501: merge changes 57202,57208,61114 into release

boost/numeric/ublas/detail/concepts.hpp libs/numeric/ublas/doc/release_notes.htm

Note: See TracTickets for help on using tickets.