前提
- 安裝 xcode
- 安裝 xcode command line tools
下載 qt-everywhere-opensource-src-5.7.1.tar.gz
tar -xzvf qt-everywhere-opensource-src-5.7.1.tar.gz
cd qt-everywhere-opensource-src-5.7.1
vi build.sh
build.sh
#!/bin/sh
./configure -static -debug-and-release -nomake examples -nomake tests -prefix ~/Qt/5.7.1_static_osx -qt-sql-sqlite -plugin-sql-sqlite -qt-libpng -qt-libjpeg -qt-zlib -qt-pcre -opensource -confirm-license -opengl -qt-freetype
chmod +x ./build.sh
./build.sh
make
make install
或者多核處理器
make -j8
make -j8 install
錯誤信息
編譯 qt 5.7.1 下出現(xiàn)錯誤
fontdatabases/mac/qfontengine_coretext.mm:775:20: error: qualified reference to
'QFixed' is a constructor name rather than a type in this context
return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
修改為
return QFixed(int(CTFontGetUnitsPerEm(ctfont)));
qt/qtbase/src/plugins/platforms/cocoa/qcocoahelpers.h
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage);
改為
void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage);
qt/qtbase/src/plugins/platforms/cocoa/qcocoahelpers.mm 改為
void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
{
// Verbatim copy if HIViewDrawCGImage (as shown on Carbon-Dev)
OSStatus err = noErr;
// require_action(inContext != NULL, InvalidContext, err = paramErr);
// require_action(inBounds != NULL, InvalidBounds, err = paramErr);
// require_action(inImage != NULL, InvalidImage, err = paramErr);
CGContextSaveGState( inContext );
CGContextTranslateCTM (inContext, 0, inBounds->origin.y + CGRectGetMaxY(*inBounds));
CGContextScaleCTM(inContext, 1, -1);
CGContextDrawImage(inContext, *inBounds, inImage);
CGContextRestoreGState(inContext);
//InvalidImage:
//InvalidBounds:
//InvalidContext:
// return err;
}