美文网首页Qt 疑难杂症
macOS 下编译 qt 静态版

macOS 下编译 qt 静态版

作者: wyrover | 来源:发表于2018-08-30 14:19 被阅读162次

    前提

    • 安装 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 下出现错误

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

    相关文章

      网友评论

        本文标题:macOS 下编译 qt 静态版

        本文链接:https://www.haomeiwen.com/subject/gqnrwftx.html