I'm trying to follow some examples to get signal and slot connections to work in Visual Studio 2013. Here's the basic code:

Qt Code:
  1. #include <QtCore/QObject>
  2.  
  3. class my_derived_object : public QObject
  4. {
  5. private:
  6. // http://qt-project.org/doc/qt-4.8/qobject.htm#Q_OBJECT
  7. // "The Q_OBJECT macro must appear in the private section of a class definition
  8. // that declares its own signals and slots or that uses other services provided
  9. // by Qt's meta-object system."
  10. Q_OBJECT;
  11.  
  12. public:
  13. // http://qt-project.org/doc/qt-4.8/qobject.html#Q_INVOKABLE
  14. // "Apply this macro to definitions of member functions to allow them to be
  15. // invoked via the meta-object system. The macro is written before the return
  16. // type..."
  17. Q_INVOKABLE int say_hi(int number)
  18. {
  19. cout << "hello with number '" << number << "'" << endl;
  20.  
  21. return (number * 2);
  22. }
  23. };
  24.  
  25. int main(int argc, char **argv)
  26. {
  27. my_derived_object my_obj;
  28.  
  29. int method_index = my_obj.metaObject()->indexOfMethod("say_hi(int)");
  30. cout << "method index = '" << method_index << "'" << endl;
  31.  
  32. return 0;
  33. }
To copy to clipboard, switch view to plain text mode 

The problem is that "Q_OBJECT" macro. Having that in my code produces a link error like so:
Qt Code:
  1. LNK2019: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall my_derived_object ::metaObject(void)const " (?metaObject@my_derived_object @@UBEPBUQMetaObject@@XZ) referenced in function _main *error location has personal folder locations and is therefore redacted*
To copy to clipboard, switch view to plain text mode 

But that macro, as per the documentation referenced in the comment above it, is required to specify my own slot and signal functions, which in turn are required for anything using SIGNAL(...) or SLOT(...), such as a call to QObject::connect(...). This code worked just dandy in QtCreator, but not in Visual Studio.

I tried a brute force approach of linking every possible Qt .lib file into my program and including all possible Qt .dll files into my project, but that did nothing. I still had the linker error.

So where does QMetaObject "live"? I've tried some "moc"-related tutorials that tried to generate certain files, but I didn't get anywhere.