[Qt-interest] Qt mocks issue multiple definition of

Alex Ivasyuv industral at gmail.com
Sun Oct 31 21:39:42 CET 2010


On 10/31/2010 10:12 PM, Scott Aron Bloom wrote:
> Turn on -Wall I bet it puts out a warning
>
Nope.
Adding

QMAKE_CXXFLAGS += -Wall -W
QMAKE_CFLAGS += -Wall -W

doesn't shows additional information.

$ make
Makefile:203: warning: overriding commands for target `MyClass.o'
Makefile:200: warning: ignoring old commands for target `MyClass.o'
g++ -c -pipe -Wall -W -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG 
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED 
-I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore 
-I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -IA -I. -o main.o main.cpp
g++ -c -pipe -Wall -W -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG 
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED 
-I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore 
-I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -IA -I. -o MyClass.o 
B/MyClass.cpp
g++ -Wl,-O1 -o adasdasdad main.o MyClass.o MyClass.o    -L/usr/lib 
-lQtGui -lQtCore -lpthread
MyClass.o: In function `MyClass::MyClass()':
MyClass.cpp:(.text+0x0): multiple definition of `MyClass::MyClass()'
MyClass.o:MyClass.cpp:(.text+0x0): first defined here
MyClass.o: In function `MyClass::MyClass()':
MyClass.cpp:(.text+0x10): multiple definition of `MyClass::MyClass()'
MyClass.o:MyClass.cpp:(.text+0x10): first defined here
MyClass.o: In function `MyClass::~MyClass()':
MyClass.cpp:(.text+0x20): multiple definition of `MyClass::~MyClass()'
MyClass.o:MyClass.cpp:(.text+0x20): first defined here
MyClass.o: In function `MyClass::~MyClass()':
MyClass.cpp:(.text+0x30): multiple definition of `MyClass::~MyClass()'
MyClass.o:MyClass.cpp:(.text+0x30): first defined here
MyClass.o: In function `MyClass::method2()':
MyClass.cpp:(.text+0x40): multiple definition of `MyClass::method2()'
MyClass.o:MyClass.cpp:(.text+0x40): first defined here
collect2: ld returned 1 exit status
make: *** [adasdasdad] Error 1

BTW, seems like -W and -Wall enabled by default...

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Pavel Koshevoy
> Sent: Sunday, October 31, 2010 1:10 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Qt mocks issue multiple definition of
>
> On 10/31/2010 1:46 PM, Alex Ivasyuv wrote:
>> Hi,
>>
>> I found an ?issue? with Qt mocks.
>> Please checkout this simple code
>> http://qttestissue.googlecode.com/svn/trunk/
>>
>> If you have the same classes names, Qt mocks create the same object
>> names for them, and as result fails with the following error:
> "multiple
>> definition of"
> Actually, your classes are named differently
> A/MyClass.* implements MyClass2
> B/MyClass.* implements MyClass
>
> The class name does not have to match the file name (as in your case
> with MyClass2), but it is a good practice that a file name matches the
> name of the class -- rename A/MyClass.* to A/MyClass2.*
>
> Other than that, this seems to be a qmake bug, it generated a Makefile
> that links the same object file twice.
>
>       Pavel.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest


-- 
Best regards,
Alex Ivasyuv
Senior WebUI Software Engineer
ReelRoles, Inc.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101031/5ce54a95/attachment.html 


More information about the Qt-interest-old mailing list