On Mon, 2005-12-26 at 19:25 -0500, Gennadiy Rozental wrote:
When I try to link a test suite I get this:
ld: multiple definitions of symbol boost::test_tools::(anonymous namespace)::check_is_close mspathCEntry_test.o definition of boost::test_tools::(anonymous namespace)::check_is_close in section (__DATA,__data) ModelBuilder_test.o definition of boost::test_tools::(anonymous namespace)::check_is_close in section (__DATA,__data) ld: multiple definitions of symbol boost::test_tools::(anonymous namespace)::check_is_small mspathCEntry_test.o definition of boost::test_tools::(anonymous namespace)::check_is_small in section (__DATA,__data) ModelBuilder_test.o definition of boost::test_tools::(anonymous namespace)::check_is_small in section (__DATA,__data) LinearProduct_test.o definition of boost::test_tools::(anonymous namespace)::check_is_close in section (__DATA,__data) LinearProduct_test.o definition of boost::test_tools::(anonymous namespace)::check_is_small in section (__DATA,__data) .....
This is with boost 1.33 on Darwin/OS-X. The same code was building OK with the 1.31 libraries (and 1.32 on linux, I think). I'm using libtool. Here's the makefile
I remember seeing similar report recently. As it clear from error message linker complains about multiple definitions for symbols in anonymous namespace. This looks like compiler bug. If you know any workarounds please share them with us.
Gennadiy
The linker flag -m ("Don't treat multiply defined symbols as a hard
error ... The first linked object is used ... This can still produce a
resulting output file that is in error. This flag's use is strongly
discouraged!") seems to work around the problem.
I see lots of questions about multiply defined symbols errors for Mac OS
X, but few answers.
I reviewed gcc bugs with "namespace" in them and found nothing that
looked relevant.
I have attempted to reproduce the problem with small test cases that
don't involve the Boost framework and have so far failed. So the error
seems pretty subtle. I've attached sample files that give the error
using boost (if you remove the -Wl,-m from LDFLAGS). Also note that
using only a single file (a.o without b.o) does not produce the error.
$ uname -a
Darwin statcluster 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30
20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power
Macintosh powerpc
$ g++ --version
g++ (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671)
This not the latest release of the software or of OS X.
I've manually added some \ where lines were broken by the mailer; the
original had on long line in those spots.
P.S. Does anyone know what's up with this warning, suppressed by
no-long-double?
/usr/local/include/boost-1_33_1/boost/type_traits/is_float.hpp:21:
warning: use
of `long double' type; its size may change in a future release
--------------------- Makefile -------------------------------
CPPFLAGS += -I/usr/local/include/boost-1_33_1
CXXFLAGS += -Wno-long-double
LDFLAGS += -L/usr/local/lib/boost-1_33_1 -lboost_unit_test_framework \
-Wl,-m
go: t
./t
t: a.o b.o
../mspath/src/libtool --mode=link --tag=CXX $(CXX) -o $@ $^ \
$(LDFLAGS)
clean:
rm *.o t
------------------------ a.cc-------------------------------
#define BOOST_AUTO_TEST_MAIN
#include