Results 1 to 6 of 6

Thread: MOC_ FIle Issue

  1. #1
    Join Date
    Apr 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default MOC_ FIle Issue

    Hi

    I have created a project (Say ProjA) which generate many moc_ files (.cpp) in main project folder. I changed the project setting in the project. The project is set up in visual studio 2010. The project is a .dll project.
    I linked this project to main project (say ProjM) in Visual Studio and provided path to the source directory for .h files. The issues is that it complains and through an error "Error 1 error LNK2001: unresolved external symbol "public: static struct QMetaObject const XXXX::staticMetaObject" (?staticMetaObject@XXXX@@2UQMetaObject@@B)

    I was unable to sort it. Then I added the the 'moc_xxxx.cpp" to the project 'ProjectM' and it seems to work. I believe that this is not the correct way of doing it. Can any one please help me.

    Regards

    Masroor

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: MOC_ FIle Issue

    If you are doing this manually you need to add the link library (*.lib) matching the DLL to the list of libraries to be linked into your project.

    You typically do this with your PRO file: Declaring other libraries.

  3. #3
    Join Date
    Apr 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: MOC_ FIle Issue

    Hi

    I added the .lib in the list. Even then the problem was there. It went off when I added the moc_ files in visual studio project. I am not using .pro but the project is created in visual studio using the qt plugin.

    Masroor
    Last edited by mhbawa; 23rd April 2014 at 23:25.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: MOC_ FIle Issue

    Then ProjA does not contain the results of compiling the moc output for the headers that were processed as part of building it.

  5. #5
    Join Date
    Apr 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: MOC_ FIle Issue

    Hi

    It is strange. The moc_ file are created in the ProjA and I set the path to be the root of Build folder rather than the default Generated folder. Then, these moc_.cpp files were added into the ProjA and the ProjA is compiling without and error. The issues arises when ProjA is added to ProjM as a New Reference Project using Visual Studio "Properties of the ProjM". Then corresponding include folders and .lib files are added. I see that error after I try to compile the ProjM.

    Many thanks.

    Masroor

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: MOC_ FIle Issue

    I think what ChrisW67 is saying is that the projects setup for ProjA is faulty, it does not build and link the code of the *_moc.cpp files.

    You could try using a .pro file and have qmake generate a VS solution from that.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 13th October 2010, 04:27
  2. XML File reading issue
    By yogesh in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2009, 14:46
  3. Multiple Definition errors in moc_<Obj>.cpp and moc_<Obj>_obj.cpp
    By Doug Broadwell in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2007, 19:10
  4. .app file Issue in MAC
    By vishal.chauhan in forum General Discussion
    Replies: 2
    Last Post: 30th March 2007, 18:41
  5. Qt 3.3.4 -> Qt 4.1.2, moc file issue
    By philski in forum Qt Tools
    Replies: 1
    Last Post: 11th September 2006, 21:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.