[Qt-interest] duplicate symbol

paulf at free.fr paulf at free.fr
Fri Oct 1 10:35:42 CEST 2010


Hi

More precisely, it is defined in more than one compilation unit. Normally, a compilation unit is the .cpp file plus all of the headers that it includes. So in addition to the possibility that the symbol is multiply defined in .cpp files, it could also be defined just once in a header that is itself included in more than one .cpp file. The result is that the symbol is multiply defined in more than one compilation unit.

Golden rule:
headers -> declarations
.cpp    -> definitions

(with exceptions for inline functions (use sparingly) and templates)

A+
Paul


----- Original Message -----
From: "Thiago Macieira" <thiago at kde.org>
To: qt-interest at trolltech.com
Sent: Friday, 1 October, 2010 10:27:11 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Re: [Qt-interest] duplicate symbol

Em Sexta-feira 01 Outubro 2010, às 09:27:55, Alexander Carôt escreveu:
> > On Friday 1. October 2010 09.00.15 Alexander Carôt wrote:
> > > ld: duplicate symbol myWidget::event(QEvent*) in soundjack.o and main.o
> > > 
> > > How can I fix this ?
> > 
> > You declared the same function in both .cpp. Remove from one.
> 
> I just did that but then I noticed that the problem is obviously not
> related to the event loop: I totally deleted the function and then got the
> same error in context with the constructor:
> 
> ld: duplicate symbol myWidget::myWidget()in soundjack.o and main.o
> 
> Do you have any further hint or is more info required ?

It's the same hint: the symbol is defined in more than one .cpp.

Note that all the #includes count as part of the .cpp.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Qt Developer Days 2010  -  Munich Oct 11-13  -  San Francisco Nov 1-3
For more information and to register: http://qt.nokia.com/qtdevdays2010

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list