[Qt-interest] Qt mocks issue multiple definition of

Pavel Koshevoy pavel at aragog.com
Sun Oct 31 21:38:03 CET 2010


On 10/31/2010 2:31 PM, Alex Ivasyuv wrote:
> On 10/31/2010 10:09 PM, Pavel Koshevoy wrote:
>> 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.*
>
> Yes, you right. I just played around...
> Done, but still the same error....

What I suggested for you to do was to rename the files A/MyClass.hpp,cpp 
to A/MyClass2.hpp,cpp
What you have done was rename MyClass2 (defined in A/MyClass.hpp,cpp ) 
to MyClass
You already have a MyClass defined int B/MyClass.hpp,cpp

Now you have multiple definitions of MyClass, in the same namespace
The linker will not like that.

     Pavel.

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


More information about the Qt-interest-old mailing list