2

I have a running project made in qt . For building purpose I m using waf build tool. To get the same project up and running from waf I need to add

#include "file.moc" 

at the end of some files to avoid undefined reference. But if these includes are not commented in qt I get can not find file errors. How do you make qt ignore certain file includes. I thought something like this should have done the trick

#ifndef Q_MOC_RUN
    #include "file.moc"
#endif
Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
  • You should be a little bit more specific. If you have to manually include `moc` files, there is a chance you are already doing something wrong. – pmr Jul 09 '12 at 08:51
  • the problem is .. To make the code run in QT I have to comment those moc file includes . But to make the same code run using WAF I have to uncomment them. – Vihaan Verma Jul 09 '12 at 08:57
  • Could it be that you are not running the `moc` compiler when you are building with `WAF`? – pmr Jul 09 '12 at 09:07
  • yeah waf runs MOC , in the output I can see moc files generated using MOC – Vihaan Verma Jul 09 '12 at 09:11

1 Answers1

0

Due to the limited information provided, all I can show is what waf can do:

You either can include the moc files or the unprocessed files.

Examples are included in the distributed source at https://code.google.com/p/waf/downloads/detail?name=waf-1.6.11.tar.bz2

Subdirectories:

  • playground/slow_qt/
  • demos/qt4/

For the sake of completness, simplified examples:

default includes

def options(opt):
opt.load('compiler_cxx qt4')

def configure(conf):
conf.load('compiler_cxx qt4')
conf.load('slow_qt4')

def build(bld):
bld(
    features = 'qt4 cxx cxxprogram',
    uselib   = 'QTCORE QTGUI QTOPENGL QTSVG',
    source   = 'some.cpp files.cpp',
    includes = '.',
    target   = 'dummy',
)

moc cpp

def options(opt):
opt.load('compiler_cxx qt4')

def configure(conf):
conf.load('compiler_cxx qt4')

 def build(bld):
bld(
    features = 'qt4 cxx cxxprogram',
    uselib   = 'QTCORE QTGUI QTOPENGL QTSVG',
    source   = 'some.cpp files.cpp',
    target   = 'dummy',
    includes = '.')
)
drahnr
  • 6,782
  • 5
  • 48
  • 75
  • I was looking for a way to avoid includes when the program is ran from qt. – Vihaan Verma Jul 11 '12 at 07:41
  • If you include your cpp files plus use the first example snippet it should be fine. No need for moc includes at all. Either way, post your exact error message. – drahnr Jul 11 '12 at 08:59