使用vc(vs2008)编译Qt5.4

2023-07-06 14:18:57 浏览数 (1)

使用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 msdo_ms nmake -f msnt.mak   nmake -f msnt.mak install 4。开始config Qt5 一个bat搞定

复制代码

  1. cd /d "C:Program Files7-Zip" call "C:Program Files (x86)Microsoft Visual Studio 9.0VCvcvarsall.bat" if exist E:qt-everywhere-opensource-src-5.4.0 ( echo "QT FIles exists" ) else ( REM 7z x D:Qtqt-everywhere-opensource-src-5.4.0.zip -oE: echo "COPY Qt 5.4.0 Source" xcopy %~dp0qt5.4-source E:qt-everywhere-opensource-src-5.4.0 /s /e /I ) rd /s /q E:qt-everywhere-opensource-src-5.4.0qtwebkit rd /s /q E:qt-everywhere-opensource-src-5.4.0qtwebkit-examples copy /y %~dp0dscamerasession.cpp  E:qt-everywhere-opensource-src-5.4.0qtmultimediasrcpluginsdirectshowcamera cd /d E:qt-everywhere-opensource-src-5.4.0 set PATH=C:Python34;C:Program Files7-Zip;�%qtbasebin;%PATH% set QTDIR=C:Qt5.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:Python34include" -I C:Build-OpenSSL-VC9-32include -L C:Build-OpenSSL-VC9-32lib -L "C:Program FilesMicrosoft SDKsWindowsv6.0ALib" -L C:Python34libs -l Gdi32 -l User32  -prefix C:Qt5.4.0 -mp nmake nmake install pause

附上文中改掉的cpp文件 找到对应位置自行修改 文件路径为qtmultimediasrcpluginsdirectshowcameradscamerasession.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.0VCINCLUDExutility(263) : error C2678: 二进制“<”: 没有找到接受“const QString”类型的左操作数的运算符(或没有可接受的转换)         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qchar.h(533): 可能是“bool operator <(QChar,QChar)”[通过使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qbytearray.h(599): 或       “bool operator <(const QByteArray &,const QByteArray &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qbytearray.h(601): 或       “bool operator <(const QByteArray &,const char *)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qbytearray.h(603): 或       “bool operator <(const char *,const QByteArray &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(625): 或       “bool operator <(const QString &,const QString &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(694): 或       “bool operator <(const char *,const QString &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(701): 或       “bool operator <(const char *,const QStringRef &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(1121): 或       “bool operator <(QLatin1String,QLatin1String)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(1178): 或       “bool operator <(const char *,QLatin1String)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(1504): 或       “bool operator <(const QStringRef &,const QStringRef &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qcollator.h(72): 或       “bool operator <(const QCollatorSortKey &,const QCollatorSortKey &)”[使用参数相关的查找找到]         f:qtqt5qtbaseincludeqtcore../../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:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(632): 或       “bool QString::operator <(QLatin1String) const”         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(680): 或       “bool QString::operator <(const char *) const”         f:qtqt5qtbaseincludeqtcore../../src/corelib/tools/qstring.h(687): 或       “bool QString::operator <(const QByteArray &) const”

由于std::lower_bound导致的问题,已解决,方法如下: 在qttoolssrcassistanthelpqhelpsearchindexwriter_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

在qt3dsrcrenderbackendjobsrenderviewjobutils_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支持不够好

0 人点赞