编译一个简单的Qt“Hello World!"Visual Studio 2010 Express 中的应用程序? [英] Compiling a simple Qt "Hello World!" application within Visual Studio 2010 Express?

查看:23
本文介绍了编译一个简单的Qt“Hello World!"Visual Studio 2010 Express 中的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个基本的 Qt你好,世界!"Visual Studio 中的应用程序.

I'm trying to build a basic Qt "Hello, world!" application inside Visual Studio.

我让 moc 步骤工作(我认为),但现在我不知道如何修复此链接器错误:

I got the moc step to work (I think), but now I am at a loss as to how to fix 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 done a lot of searching but I am at a loss.

这是我的包含目录:

  • 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;
  • rease;
  • .;
  • i:\Qt\4.6.3\mkspecs\win32-msvc2008

以下是我要链接的库:

  • 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;

有人有什么想法吗?

推荐答案

qmake 将从 .pro 文件中的头文件生成 moc voodoo.由于您没有使用 qmake,从它的声音来看,它是一个原生的 Visual Studio 项目,这可能是问题的原因.

qmake will generate the moc voodoo from the header file in .pro file. As you aren't using qmake, by the sound of it, but a native visual studio project, this is probably the cause of the problem.

如果你使用 qmake 来生成你的 Visual Studio 项目,你所有的问题都会消失,生活会很甜蜜.大概!

If you use qmake to generate your visual studio project all your problems will go away and life will be sweet. Probably!

我用的是2010.05开放的;显然你想用正确的路径替换你的版本.

I am using the open 2010.05; obviously you want to substitute the correct path for your version.

设置环境

从开始菜单启动 2010 命令环境
-set include=%include%;C:\Qt\2010.05\qt\include
-set lib=%lib%;C:\Qt\2010.05\qt\lib-set path=%path%;C:\Qt\2010.05\qt\bin
-set QMAKESPEC=win32-msvc2010

start 2010 command environment from the start menu
-set include=%include%;C:\Qt\2010.05\qt\include
-set lib=%lib%;C:\Qt\2010.05\qt\lib -set path=%path%;C:\Qt\2010.05\qt\bin
-set QMAKESPEC=win32-msvc2010

编写代码,创建文件等

生成初始 pro 和 makefile 并启动 VS
-qmake -tp vc
-qmake

generate the initial pro and makefile and fire up VS
-qmake -tp vc
-qmake

您现在应该有一个 makefile - 通过运行来检查它是否有效:
-nmake

you should now have a makefile - check that it works by running:
-nmake

现在启动视觉工作室
-VCExpress.exe/useenv
-XXX.vcxproj 现在可以打开

now launch visual studio
-VCExpress.exe /useenv
-XXX.vcxproj can now be opened

如果这不起作用,您可能需要针对 Visual Studio 构建 qt.这非常简单 - 转到 qt 目录(从 Visual Studio express 命令窗口中)并键入:

If this doesn't work you may need to build qt at against visual studio. This is very straightforward - go to the qt directory (from within the visual studio express command window) and type:

configure.exe -platform win32-msvc2010 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-multimedia -no-qt3support -fast

这篇关于编译一个简单的Qt“Hello World!"Visual Studio 2010 Express 中的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆