PDA

View Full Version : MOC_ FIle Issue



mhbawa
23rd April 2014, 19:41
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

ChrisW67
23rd April 2014, 21:47
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.

mhbawa
23rd April 2014, 23:25
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

ChrisW67
24th April 2014, 00:58
Then ProjA does not contain the results of compiling the moc output for the headers that were processed as part of building it.

mhbawa
24th April 2014, 02:25
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

anda_skoa
24th April 2014, 09:38
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,
_