[Interest] Failed to make moc for cpp source file.

Igor Mironchik igor.mironchik at gmail.com
Tue Feb 10 14:39:20 CET 2015


On Tue, 10 Feb 2015 14:35:35 +0300, Bo Thorsen <bo at vikingsoft.eu> wrote:

> Den 10-02-2015 kl. 10:30 skrev Igor Mironchik:
>> Hi. I ran into a problem.
>>
>> When building project for Android target, build doesn't make moc for a  
>> cpp
>> file and compilation failed.
>>
>> In that cpp I have Q_OBJECT and #include "messagebox.moc"
>>
>> In Makefile generated I have:
>>
>> mocables: compiler_moc_header_make_all compiler_moc_source_make_all
>>
>> compiler_moc_source_make_all: .moc\messagebox.moc
>>
>> But I got:
>>
>> ..\..\..\Mobile\QtMWidgets\src\messagebox.cpp:622:26: fatal error:
>> messagebox.moc: No such file or directory
>>    #include "messagebox.moc"
>>                             ^
>> compilation terminated.
>
> Hi Igor,
>
> I was just working on a fix for a qmake bug that involves exactly this  
> case. In my bug there was a place in the code that said "foo""bar" and  
> the workaround is to do "foo" "bar" (notice the space between the two  
> strings). It's bug 17533 in the Qt bugtracker.
>
> I guess you hit a bug related this.
>
> You can check if you are hit by a similar bug. Check the Makefile and  
> look for the rule to build messagebox.o - it has to list messagebox.moc  
> at the end of the list of dependency files. If it's not there, your moc  
> file won't be built.
>
> Unfortunately I can't tell you how to work around it, if it is the same  
> problem, because there might be other ways to trigger it. The way I  
> would work around this is to remove almost all the code in the file and  
> see if you can get the moc file to show up as a dependency and then  
> re-add the code until it disappears from the list. Then you can find the  
> place where your code stops the moc dependency check from working and  
> try to find a way to work around it.
>
> For reference, my Makefile.Debug on Windows has this in the file:
>
> ####### Compile
>
> debug\main.obj: main.cpp ..\build-5.4\include\QtCore\QtCore \
>                  ..\build-5.4\include\QtCore\QtCoreDepends \
>                  debug\main.moc
>
> I just saw your second message on this, and you don't get the Makefile.  
> So I don't know if this is helpful at all. But the dependency check in  
> qmake should be the same for your project generator, so it could be.

Hi.

May be you are right. Unfortunately, I don't have that Makefile that makes  
compillation error...

-- 
Best Regards,
Igor Mironchik.



More information about the Interest mailing list