qtmocqtremoteobjects

How to manually repc Qt .rep to .h and then moc them to .cpp


I'm trying to manually calling repc on my .rep files then running moc on the header output files.
repc runs successfully, but moc randomly complains about a

parse error at '('

after a Q_CLASSINFO declaration. Any seen that issue before?

Example:

remoteminimal.rep

class RemoteMinimal
{
    SIGNAL(sendData(const QString &, const QString &));
    SLOT(void printData(const QString &));
    SLOT(void process(const QString &, const QString &));
    SLOT(void triggerSendData());
};

do

repc -i rep remoteminimal.rep -o replica rep_min_test.h

then

moc -o moc_rep_min_test.cpp rep_min_test.h

you'll get the following error:

rep_min_test.h:20: Parse error at "("


Solution

  • The problem is that you are not linking Qt so MOC does not find some definitions. For these cases I prefer to analyze the code generated by qmake, and in the following fragment:

    /usr/bin/moc ... rep_remoteminimal_replica.h -o moc_rep_remoteminimal_replica.cpp -I /usr/include/qt -I /usr/include/qt/QtRemoteObjects
    

    You see that it is linked /usr/include/qt:

    moc -I/usr/include/qt rep_min_test.h -o moc_rep_min_test.cpp