首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >使用vc(vs2008)编译Qt5.4

使用vc(vs2008)编译Qt5.4

作者头像
用户3519280
发布2023-07-06 14:18:57
发布2023-07-06 14:18:57
5390
举报
文章被收录于专栏:c++ 学习分享c++ 学习分享

使用vc(vs2008)编译Qt5.4

官方的Qt 只有vc10以上的版本 若是想vc9 只能自己编译 so 开始干 搜索资料 1)vc9不能支持webkit的编译 直接删除掉 2)有部分地方 vc9默认支持LONG转ULONG 需要自己改代码 3)需要OPENSSL 4)需要python3.4.3 5)需要activePerl开工 1。下载安装activeperl 2。下载安装python3.4.3 3。编译openssl 0.9.8k perl Configure VC-WIN32 –prefix=C:\Build-OpenSSL-VC9-32 ms\do_ms nmake -f ms\nt.mak   nmake -f ms\nt.mak install 4。开始config Qt5 一个bat搞定

复制代码

  1. cd /d "C:\Program Files\7-Zip" call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" if exist E:\qt-everywhere-opensource-src-5.4.0 ( echo "QT FIles exists" ) else ( REM 7z x D:\Qt\qt-everywhere-opensource-src-5.4.0.zip -oE:\ echo "COPY Qt 5.4.0 Source" xcopy %~dp0\qt5.4-source E:\qt-everywhere-opensource-src-5.4.0 /s /e /I ) rd /s /q E:\qt-everywhere-opensource-src-5.4.0\qtwebkit rd /s /q E:\qt-everywhere-opensource-src-5.4.0\qtwebkit-examples copy /y %~dp0\dscamerasession.cpp  E:\qt-everywhere-opensource-src-5.4.0\qtmultimedia\src\plugins\directshow\camera cd /d E:\qt-everywhere-opensource-src-5.4.0 set PATH=C:\Python34;C:\Program Files\7-Zip;%CD%\qtbase\bin;%PATH% set QTDIR=C:\Qt\5.4.0 configure.bat -developer-build -opensource -nomake examples -nomake tests -mp -confirm-license -opengl desktop -no-icu -skip qtserialport -platform win32-msvc2008 -openssl-linked OPENSSL_LIBS="-lssleay32 -llibeay32" -I "C:\Python34\include" -I C:\Build-OpenSSL-VC9-32\include -L C:\Build-OpenSSL-VC9-32\lib -L "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" -L C:\Python34\libs -l Gdi32 -l User32  -prefix C:\Qt\5.4.0 -mp nmake nmake install pause

附上文中改掉的cpp文件 找到对应位置自行修改 文件路径为qtmultimedia\src\plugins\directshow\camera\dscamerasession.cpp

复制代码

  1. STDMETHODIMP_(ULONG) AddRef()     {         #if _MSC_VER==1500             volatile LONG *p_ref=reinterpret_cast<volatile LONG *>(&m_ref);             return InterlockedIncrement(p_ref);         #else             return InterlockedIncrement(&m_ref);         #endif     }     STDMETHODIMP_(ULONG) Release()     {         #if _MSC_VER==1500             volatile LONG *p_ref=reinterpret_cast<volatile LONG *>(&m_ref);             ULONG ref = InterlockedDecrement(p_ref);         #else             ULONG ref = InterlockedDecrement(&m_ref);         #endif         if (ref == 0)             delete this;         return ref;     }

完工 从此告别恼人的xp问题

按照你的方法编译5.5,部分模块编译成功,一部分出错(qttools 出错,其他依赖它的模块也编译不过去),错误如下,有谁知道什么原因?查了很久没查到什么原因导致的。 D:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(263) : error C2678: 二进制“<”: 没有找到接受“const QString”类型的左操作数的运算符(或没有可接受的转换)         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qchar.h(533): 可能是“bool operator <(QChar,QChar)”[通过使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qbytearray.h(599): 或       “bool operator <(const QByteArray &,const QByteArray &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qbytearray.h(601): 或       “bool operator <(const QByteArray &,const char *)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qbytearray.h(603): 或       “bool operator <(const char *,const QByteArray &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(625): 或       “bool operator <(const QString &,const QString &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(694): 或       “bool operator <(const char *,const QString &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(701): 或       “bool operator <(const char *,const QStringRef &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(1121): 或       “bool operator <(QLatin1String,QLatin1String)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(1178): 或       “bool operator <(const char *,QLatin1String)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(1504): 或       “bool operator <(const QStringRef &,const QStringRef &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qcollator.h(72): 或       “bool operator <(const QCollatorSortKey &,const QCollatorSortKey &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qelapsedtimer.h(80): 或       “bool operator <(const QElapsedTimer &,const QElapsedTimer &) throw()”[使用参数相关的查找找到]         .\qhelpsearchindexwriter_clucene.cpp(329): 或       “bool fulltextsearch::clucene::operator <(const fulltextsearch::clucene::QTextHtmlEntity &,const QString &)”[使用参数相关的查找找到]         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(632): 或       “bool QString::operator <(QLatin1String) const”         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(680): 或       “bool QString::operator <(const char *) const”         f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(687): 或       “bool QString::operator <(const QByteArray &) const”

由于std::lower_bound导致的问题,已解决,方法如下: 在qttools\src\assistant\help\qhelpsearchindexwriter_clucene.cpp增加如下代码:

复制代码

  1. #if defined(Q_CC_MSVC) && _MSC_VER < 1600 //The STL implementation of MSVC 2008 requires the definitions static bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2) {     return QLatin1String(entity1.name) < QLatin1String(entity2.name); } static bool operator<(const QString &entityStr, const QTextHtmlEntity &entity) {     return entityStr < QLatin1String(entity.name); } #endif

在qt3d\src\render\backend\jobs\renderviewjobutils_p.h修改如下代码:

复制代码

  1. struct ParameterInfo {     ParameterInfo(const QString &name = QString(), const QVariant &value = QVariant())         : name(name)         , value(value)     {}     QString name;     QVariant value;     bool operator<(const QString &otherName) const     {         return name < otherName;     }     bool operator<(const ParameterInfo &other) const     {         return name < other.name;     } }; #if defined(Q_CC_MSVC) && _MSC_VER < 1600 //The STL implementation of MSVC 2008 requires the definitions static bool operator<(const QString &name, const ParameterInfo &pi) {     return name < pi.name; } #endif

唯一的缺陷是c++11支持不够好

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-06-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 使用vc(vs2008)编译Qt5.4
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档