Question

I'm trying to move my project from the VS2005 build system to Qt Creator.

We've set up visual studio to use moc for certain headers and output a .moc file with the same file name.

eg:
MyClass.h

MyClass.moc

When QtCreator runs qmake and moc is run, it generates a cpp file with the file name prepended with moc_

eg: MyClass.h

moc_MyClass.cpp

I've found options for changing where moc outputs its files, but now how to change the actual output filename. In our visual studio files we have basically

-o $(InputName).moc

Is there an equivalent way to do this in Qt Creator? I'm guessing it's something I put in my .pro file.

EDIT:

I've made some progress on my issue.

I found some documentation on how to have custom compilers and targets here and here.

I've set up my 'new moc' tool to output moc files in the same directory as the header and name them as .moc files.

new_moc.output = ${QMAKE_FILE_BASE}.moc
new_moc.commands = moc ${QMAKE_FILE_NAME} -o
${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_OUT}
new_moc.input = NEW_HEADERS

new_moc_echo.commands = @echo Moccing $$new_moc.target

QMAKE_EXTRA_COMPILERS += new_moc
QMAKE_EXTRA_TARGETS += new_moc_echo

It builds the moc file in the right place, however, I now get a linker error for my project.

MyFile.moc : fatal error LNK1107: invalid or corrupt file: cannot read at 0xA02

I'm guessing something's missing from my moc build tool.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top