views:

646

answers:

2

I'm trying to build a basic Qt hello world inside visual studio.

I got the moc step to work (i think), but I am at a loss as to how to pass this linker error..

1>moc_mainwindow.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QMainWindow::staticMetaObject" (?staticMetaObject@QMainWindow@@2UQMetaObject@@B)

I've pleanty of googling but I am really at a loss.

here is my include directories:

i:\Qt\4.6.3\include\QtCore; i:\Qt\4.6.3\include\QtGui; i:\Qt\4.6.3\include; i:\Qt\4.6.3\include\ActiveQt; release; .; i:\Qt\4.6.3\mkspecs\win32-msvc2008

here is my libs linked:

i:\Qt\4.6.3\lib\QtGui4.lib; i:\Qt\4.6.3\lib\QtCore4.lib; gdi32.lib; comdlg32.lib; oleaut32.lib; imm32.lib; winmm.lib; winspool.lib; ws2_32.lib; ole32.lib; user32.lib; advapi32.lib; libpng.lib; msimg32.lib; shell32.lib; kernel32.lib; uuid.lib;

still need help with this.. :p anyone out there?

A: 

Have you create the visual studio project using qmake first? The problem seems to be the moc compilation. Do you have qt plug-in installed and the qt path in enviromental variables? Can you add you hello world code so I can have a look at it?

cnebrera
its express, cant install a plugin.. and the code is more than just hello world.. its currently a commandline program.. that I'm adding a basic qt empty window up with the generic auto created classes.QApplication a(argc, argv);MainWindow w;w.show();return a.exec();
Evil Spork
If you cannot install the plugin in the express edition I'm not sure I can help. You need to be able to create the moc files, I'm sure you can do that manually from the command line and then try to change the visual studio parameters to do the compilation. However I doubt the debugger is going to work very well in that case since it will probably try to debug the moc code with the signals and other Qt macros in pure C++ code. Why don't you try QtCreator or Eclipse? Do you need specific visual studio functionality?
cnebrera
it compiles fine in QtCreator, thats not the issue. the issue is, I /need/ to use visual studio 2008 or 2010.. and i only have express.
Evil Spork
That make things very complex. I have no idea if is possible to compile in visual studio without the pug-in and even if you can, as I said before probably the debugger is going to be very hard to use. I know is a pain in the ass but I would get the standard edition if it is really compulsory for you to use visual studio. I'm sorry not being able to help you further.
cnebrera
okay, i got the standard version.. painful to have to shell out for this.. but even more painful that i get the same error. so how do I solve it now?
Evil Spork
Do you have the visual studio qt plugin installed and the qt bin directory in the path and have created the visual studio project from your pro file calling qmake -t vcapp?
cnebrera
yes I created it by calling "qmake.exe -tp vc -spec win32-msvc2008", i installed the qt plugin, and its all pathed up.
Evil Spork
I have no idea of where is the problem I'm sorry :(. I'm using visual studio 2008 with the plug-in and I have no problems at all.
cnebrera
+2  A: 

You cannot install the Qt VS plugin on the Express edition of VC++. Assuming you got the moc to compile, you also need to make sure you're including the appropriate libraries (*.lib files) at link time. This goes under Project properties > Linker > Input > Additional Dependencies.

You will need qtcore4.lib at a minimum.

Also make sure the Qt library path is in your library search path. On my computer it's c:\qt\4.6.2\lib.

Ben Herila
aye, I built the project using qmake, and it added the libs (which i had to modify a little) I'll update with a list of included libs and paths.
Evil Spork