window+vc.net环境下QT4的安装--中文

weixin_38062424 2019-09-19 11:39:16
这几天使用QT,看到这片http://www.qtcn.org/bbs/read.php?tid=3449关于安装的文章不错,就以自己的这点e文水平翻译了一下,供大家学习参考,如果哪里有上面不妥的,请提意见。谢谢!源文地址:http://qtnode.net/wiki/Qt4_with_Visual_Studio编译QT4.1.1-、获取和安装QT 4.1.1   1.获得Qt源码压缩包qt-win-opensource-src-4.1.1.zip(http://www.qtcn.org/download/qt-win-opensource-src-4.1.1.zip)   2.解压源码包,建议路径:     C:\Qt\4.1.1\         (如果使用VC6.0)     C:\Qt\4.1.1-msvc\     (如果使用VC.net 20003)       C:\Qt\4.1.1-msvc2005\   (如果使用vc2005)二、获取QT 4.1.1补丁Qtnode-acs-qt4.1.1.zip,用于windows下安装QT 4.1.1(http://www.qtcn.org/download/qt-win-opensource-src-4.1.1.zip),解压补丁包到上面的对应的目录。三、准备开始编译QT 4.1.1   打开一个命令行定位QT源码目录(根据上面的目录),必须确保设置好你的编译器路径(主要是环境变量path,include及lib里必须包含vc的相关路径)   建议:如果使用vc6.0,在命令行运行vcvars32.bat;       如果使用vc.net 2003或者2005,直接从VC的工具里运行命令行(开始->程序->VC.net->vc.net tools->vc .net command prompt)   测试你是否正确的设置好环境的方法是在当前命令行下运行nmake /?   例如:C:\Qt\4.1.1> nmake /?     Microsoft (R) Program Maintenance Utility Version 8.00.50727.42     Copyright (C) Microsoft Corporation. All rights reserved.     Usage: NMAKE @commandfile         NMAKE [options] [/f makefile] [/x stderrfile] [macrodefs] [targets]     Options:     ....   出现上面的提示,说明的你的环境已经OK了   四、打补丁;如果QT源码目录下已经有补丁文件的话,直接运行installpatch411.bat     C:\Qt\4.1.1> installpatch411.bat     你将看到:   C:\Qt\4.1.1> installpatch411.bat   patching file qconfigure.bat   patching file examples/threads/waitconditions/waitconditions.pro   patching file misc/bcc32pch/Makefile.win32-borland   patching file misc/bcc32pch/bcc32pch.cpp   patching file misc/bcc32pch/bcc32pch.pri   patching file misc/bcc32pch/bcc32pch.pro   patching file mkspecs/win32-bccx/qmake.conf   ......   ......   ......   patching file tools/porting/src/rpptreeevaluator.cpp   patching file tools/porting/src/rpptreewalker.cpp   patching file tools/porting/src/src.pro   Press any key to continue . . .   Now run qconfigure.bat   五、配置Qt和编译qmake   在这里我们不是QT自带的标准的configure.exe,而使用补丁中qconfigure.bat;如果你想改变编译选项的话,可以运行configure.exe --help查看相关的选项。   运行configure.exe --help   将会列出所有的选项,你可以通过打星号选择自己感兴趣的。已经打星号的是默认选项。   在这里我们使用补丁中qconfigure.bat,qconfigure.ba需要编译器作为参数     * msvc   <- if you are using Visual Studio 6.0     * msvc.net   <- if you are using Visual Studio .NET (2003)     * msvc2005   <- if you are using Visual Studio 2005     运行了qconfigure.bat后,会有三次提示:   a. 接受GPL license,敲'y';   b.开始编译qmake,敲'y';   c.建立makefile,敲'y'.     接着你会看到提示信息:   ====================================================     You are now ready to build Qt (msvc2005)     If you specified -static, type 'nmake sub-src'         otherwise, type 'nmake'     To start over, type 'nmake distclean'   and then re-run qconfigure.bat     ====================================================   大概是说:要编译静态库使用'namke sub-src',否则使用'nmake'   结束后 敲入'nmake distclean'并且重新运行'qconfigure.bat'六、编译QT库:   C:\Qt\4.1.1> nmake         (编译非静态库, 通常情况)   C:\Qt\4.1.1> nmake sub-src   (编译静态库)   waiting............   七、建立环境:   有很多建立环境的方法,这里使用最简单的一种   设置QT 库的路径,根据你的源码的存放目录,在环境变量path增加C:\Qt\4.1.2\bin,lib中增加C:\Qt\4.1.2\lib,include中增加C:\Qt\4.1.2\include   设置windows环境变量,详细参考   http://www.cs.usask.ca/grads/wew036/latex/env.html   当环境变量改变后,必须重新打开命令行!八、检查环境便量path:   C:\> qmake -v   QMake version: 2.00a   Using Qt version 4.1.2 in C:\Qt\4.1.2\lib九、检查QMAKESPEC   C:\> echo %QMAKESPEC%   win32-msvc.net   十、测试你的安装   1.首先测试命令行(例子:hello)   a.建立一个hello.cpp,内容如下:     #include <QApplication>     #include <QLabel>         int main(int argc, char **argv) {       QApplication app(argc, argv);       QLabel *label = new QLabel("Hello World!");             label->show();           return app.exec();     }   b.用qmake创建一个工程文件       prompt> qmake -project -o hello.pro       在你的工程目录下出现了一个hello.pro,用来生成makefile   c.用qmake创建Makefile,在命令行直接运行qmake       prompt> qmake       d.编辑你的程序     prompt> nmake   e.运行你的程序     prompt> debug\hello       2.创建visual studio工程   a.根据上面的方法创建一个工程hello.pro   b.创建适用于vc.net的hello.vcproj     prompt> qmake -project -t vcapp -o hello.pro     prompt> qmake     这样你的工程目录下就有了hello.vcproj工程文件,你就可以在vc.net中打开它了     十一、维护visual studio工程       给工程中增加文件时,可以通过编辑.pro文件并且重新运行qmake,唯一的问题就是.sln的内容不能再用,必须通过重新打开.vcproj来更新。     十二、略     。。。。。。。。。。。   十三、略     。。。。。。。。。。
...全文
22 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38066087 2019-09-19
  • 打赏
  • 举报
回复
早知道你这有翻译的,我就不看英文版的啦
weixin_38067090 2019-09-19
  • 打赏
  • 举报
回复
这东西应该置顶.命令提示符只是在运行的时候读取环境配置,如果使用qmake的时候出现如下提示'qmake' 不是内部或外部命令,也不是可运行的程序或批处理文件。重新启动命令提示符就可以了
weixin_38079250 2019-09-19
  • 打赏
  • 举报
回复
我执行到第四步,直接运行installpatch411.bat出现下述内容:请教大家,有没有谁知道是什么原因,该怎么改正?谢谢!patching file qconfigure.batcan't find file to patch at input line 111Perhaps you used the wrong -p or --strip option?The text leading up to this was:--------------------------|Index: examples/threads/waitconditions/waitconditions.pro|===================================================================|RCS file: /cvsroot/qtwin/qt-4/examples/threads/waitconditions/waitconditions.pro,v|retrieving revision 1.1.1.4|retrieving revision 1.4|diff -u -r1.1.1.4 -r1.4|--- examples/threads/waitconditions/waitconditions.pro 20 Dec 2005 19:47:47 -0000      1.1.1.4|+++ examples/threads/waitconditions/waitconditions.pro 21 Dec 2005 19:53:50 -0000      1.4--------------------------File to patch:
vc++利用ADOX创建数据库 // ADOXCreateDatabaseDlg.cpp : implementation file // #include "stdafx.h" #include "ADOXCreateDatabase.h" #include "ADOXCreateDatabaseDlg.h" #include "Shlwapi.h" #pragma comment(lib,"shlwapi.lib") // Download by http://www.codefans.net #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CADOXCreateDatabaseDlg dialog CADOXCreateDatabaseDlg::CADOXCreateDatabaseDlg(CWnd* pParent /*=NULL*/) : CDialog(CADOXCreateDatabaseDlg::IDD, pParent) { //{{AFX_DATA_INIT(CADOXCreateDatabaseDlg) m_dbName = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CADOXCreateDatabaseDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CADOXCreateDatabaseDlg) DDX_Text(pDX, IDC_DBNAME, m_dbName); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CADOXCreateDatabaseDlg, CDialog) //{{AFX_MSG_MAP(CADOXCreateDatabaseDlg) ON_WM_SYSCOMM

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧