MacOS Catalina 从源码构建Qt6.2开发库之01: 编译Qt6.2源代码

devtools/2024/9/19 17:32:24/ 标签: macos, c++, QT

安装xcode, cmake, ninja

 brew install node

mac下安装OpenGL库并使之对各项目可见

macOS上安装OpenGL通常涉及到安装一些依赖库,如MGLGLUT或者是GLEW等,同时确保LLVMOpenGL框架和相关工具链的兼容性。以下是一个基本的安装步骤,你可以在终端中执行:

  1. 安装Homebrew(如果还没有安装的话):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  2.  
  3. 安装MGLMac上的OpenGL开发库):
    brew install mgl

  4.  
  5. 安装GLUTOpenGL Utility Toolkit):
    brew install freeglut




  6. 对于较旧的系统,你可能需要安装GLUT的较旧版本:
    brew install freeglut --with-contrib

  7.  
  8. 安装GLEWOpenGL Extension Wrangler Library):
    brew install glew

  9.  
  10. 配置你的项目
    每个步骤之后,确保你的工作目录下有相应的头文件和库文件路径。你可以通过在.pro文件(对于Qt项目)或适当的地方设置C_INCLUDE_PATHLIBRARY_PATH环境变量来设置路径。
  11. 添加环境变量
    export CPPFLAGS="-I/usr/local/opt/glew/include"
  12. export LDFLAGS="-L/usr/local/opt/glew/lib"




  13. 如果你需要重复使用这些环境变量,可以将它们添加到你的.bash_profile.zshrc文件中。
  14. 编译和链接你的程序
    在编译和链接你的OpenGL程序时,确保你的构建系统(如CMakeMakefileIDE)能够找到这些库和头文件。

解压qt-everywhere-src-6.2.0.tar.xz到/Volumes/MacOS/Program/, 将目录名改为qt6.2.0

终端窗口进入/Volumes/MacOS/Program/qt6.2.0/,执行:

./configure

用CMake打开项目,设置安装目录为/usr/local

cmake —build . —parallel

修改下面的文件,明确链接OpenGL:

/Volumes/MacOS/Program/qt6.2.0/qtbase/src/plugins/platforms/cocoa/CMakeLists.txt

# Generated from cocoa.pro.

# special case:

#####################################################################

## QCocoaIntegrationPlugin Plugin:

#####################################################################

# 找到 OpenGL

find_package(OpenGL REQUIRED)

qt_internal_add_plugin(QCocoaIntegrationPlugin

    OUTPUT_NAME qcocoa

    DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES cocoa # special case

    PLUGIN_TYPE platforms

    SOURCES

        main.mm

        qcocoaapplication.h qcocoaapplication.mm

        qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm

        qcocoabackingstore.h qcocoabackingstore.mm

        qcocoaclipboard.h qcocoaclipboard.mm

        qcocoacolordialoghelper.h qcocoacolordialoghelper.mm

        qcocoacursor.h qcocoacursor.mm

        qcocoadrag.h qcocoadrag.mm

        qcocoaeventdispatcher.h qcocoaeventdispatcher.mm

        qcocoafiledialoghelper.h qcocoafiledialoghelper.mm

        qcocoafontdialoghelper.h qcocoafontdialoghelper.mm

        qcocoahelpers.h qcocoahelpers.mm

        qcocoainputcontext.h qcocoainputcontext.mm

        qcocoaintegration.h qcocoaintegration.mm

        qcocoaintrospection.h qcocoaintrospection.mm

        qcocoamenu.h qcocoamenu.mm

        qcocoamenubar.h qcocoamenubar.mm

        qcocoamenuitem.h qcocoamenuitem.mm

        qcocoamenuloader.h qcocoamenuloader.mm

        qcocoamimetypes.h qcocoamimetypes.mm

        qcocoanativeinterface.h qcocoanativeinterface.mm

        qcocoansmenu.h qcocoansmenu.mm

        qcocoascreen.h qcocoascreen.mm

        qcocoaservices.h qcocoaservices.mm

        qcocoasystemtrayicon.h qcocoasystemtrayicon.mm

        qcocoatheme.h qcocoatheme.mm

        qcocoawindow.h qcocoawindow.mm

        qcocoawindowmanager.h qcocoawindowmanager.mm

        qiosurfacegraphicsbuffer.h qiosurfacegraphicsbuffer.mm

        qmacclipboard.h qmacclipboard.mm

        qmultitouch_mac.mm qmultitouch_mac_p.h

        qnsview.h qnsview.mm

        qnswindow.h qnswindow.mm

        qnswindowdelegate.h qnswindowdelegate.mm

        qcocoacolordialoghelper.h qcocoacolordialoghelper.mm

        qcocoafiledialoghelper.h qcocoafiledialoghelper.mm

        qcocoafontdialoghelper.h qcocoafontdialoghelper.mm

    DEFINES

        QT_NO_FOREACH

    LIBRARIES

        ${FWAppKit}

        ${FWCarbon}

        ${FWCoreServices}

        ${FWCoreVideo}

        ${FWIOKit}

        ${FWIOSurface}

        ${FWMetal}

        ${FWQuartzCore}

        Qt::Core

        Qt::CorePrivate

        Qt::Gui

        Qt::GuiPrivate

        OpenGL::GL  # 添加 OpenGL 库链接

)

# special case begin

qt_disable_apple_app_extension_api_only(QCocoaIntegrationPlugin)

# special case end

# Resources:

set(qcocoaresources_resource_files

    "images/sizeallcursor.png"

    "images/spincursor.png"

    "images/waitcursor.png"

)

qt_internal_add_resource(QCocoaIntegrationPlugin "qcocoaresources"

    PREFIX

        "/qt-project.org/mac/cursors"

    FILES

        ${qcocoaresources_resource_files}

)

#### Keys ignored in scope 1:.:.:cocoa.pro:<TRUE>:

# OTHER_FILES = "cocoa.json"

## Scopes:

#####################################################################

qt_internal_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_opengl

    SOURCES

        qcocoaglcontext.h qcocoaglcontext.mm

    LIBRARIES

        OpenGL::GL # 添加OpenGL

)

qt_internal_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_vulkan

    SOURCES

        qcocoavulkaninstance.h qcocoavulkaninstance.mm

   LIBRARIES

        OpenGL::GL # 添加OpenGL

)

qt_internal_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_accessibility

    SOURCES

        qcocoaaccessibility.h qcocoaaccessibility.mm

        qcocoaaccessibilityelement.h qcocoaaccessibilityelement.mm

    LIBRARIES

        OpenGL::GL # 添加OpenGL

)

qt_internal_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager

    SOURCES

        qcocoasessionmanager.cpp qcocoasessionmanager.h

    LIBRARIES

        OpenGL::GL # 添加OpenGL

)

#### Keys ignored in scope 7:.:.:cocoa.pro:TARGET Qt::Widgets:

# QT_FOR_CONFIG = "widgets"

#### Keys ignored in scope 12:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:

# PLUGIN_EXTENDS = "-"

/Volumes/MacOS/Program/qt=6.2.0/qtbase/src/opengl/CMakeLists.txt

# Generated from opengl.pro.

#####################################################################

## OpenGL Module:

#####################################################################

qt_internal_add_module(OpenGL

SOURCES

qopengl2pexvertexarray.cpp qopengl2pexvertexarray_p.h

qopenglbuffer.cpp qopenglbuffer.h

qopenglcustomshaderstage.cpp qopenglcustomshaderstage_p.h

qopengldebug.cpp qopengldebug.h

qopenglengineshadermanager.cpp qopenglengineshadermanager_p.h

qopenglengineshadersource_p.h

qopenglframebufferobject.cpp qopenglframebufferobject.h qopenglframebufferobject_p.h

qopenglgradientcache.cpp qopenglgradientcache_p.h

qopenglpaintdevice.cpp qopenglpaintdevice.h qopenglpaintdevice_p.h

qopenglpaintengine.cpp qopenglpaintengine_p.h

qopenglpixeltransferoptions.cpp qopenglpixeltransferoptions.h

qopenglshadercache_p.h

qopenglshaderprogram.cpp qopenglshaderprogram.h

qopengltexture.cpp qopengltexture.h qopengltexture_p.h

qopengltextureblitter.cpp qopengltextureblitter.h

qopengltexturecache.cpp qopengltexturecache_p.h

qopengltextureglyphcache.cpp qopengltextureglyphcache_p.h

qopengltexturehelper.cpp qopengltexturehelper_p.h

qopengltextureuploader.cpp qopengltextureuploader_p.h

qopenglversionfunctions.cpp qopenglversionfunctions.h qopenglversionfunctions_p.h

qopenglversionfunctionsfactory.cpp qopenglversionfunctionsfactory.h

qopenglversionprofile.cpp qopenglversionprofile.h

qopenglvertexarrayobject.cpp qopenglvertexarrayobject.h

qopenglwindow.cpp qopenglwindow.h

qplatformbackingstoreopenglsupport.cpp qplatformbackingstoreopenglsupport.h

qtopenglglobal.h

DEFINES

QT_NO_FOREACH

QT_NO_USING_NAMESPACE

LIBRARIES

Qt::CorePrivate

Qt::GuiPrivate

PUBLIC_LIBRARIES

Qt::Core

Qt::Gui

PRIVATE_MODULE_INTERFACE

Qt::CorePrivate

Qt::GuiPrivate

)

## Scopes:

#####################################################################

qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_opengles2

SOURCES

qopenglfunctions_es2.cpp qopenglfunctions_es2.h

)

qt_internal_extend_target(OpenGL CONDITION NOT QT_FEATURE_opengles2

SOURCES

qopenglfunctions_1_0.cpp qopenglfunctions_1_0.h

qopenglfunctions_1_1.cpp qopenglfunctions_1_1.h

qopenglfunctions_1_2.cpp qopenglfunctions_1_2.h

qopenglfunctions_1_3.cpp qopenglfunctions_1_3.h

qopenglfunctions_1_4.cpp qopenglfunctions_1_4.h

qopenglfunctions_1_5.cpp qopenglfunctions_1_5.h

qopenglfunctions_2_0.cpp qopenglfunctions_2_0.h

qopenglfunctions_2_1.cpp qopenglfunctions_2_1.h

qopenglfunctions_3_0.cpp qopenglfunctions_3_0.h

qopenglfunctions_3_1.cpp qopenglfunctions_3_1.h

qopenglfunctions_3_2_compatibility.cpp qopenglfunctions_3_2_compatibility.h

qopenglfunctions_3_2_core.cpp qopenglfunctions_3_2_core.h

qopenglfunctions_3_3_compatibility.cpp qopenglfunctions_3_3_compatibility.h

qopenglfunctions_3_3_core.cpp qopenglfunctions_3_3_core.h

qopenglfunctions_4_0_compatibility.cpp qopenglfunctions_4_0_compatibility.h

qopenglfunctions_4_0_core.cpp qopenglfunctions_4_0_core.h

qopenglfunctions_4_1_compatibility.cpp qopenglfunctions_4_1_compatibility.h

qopenglfunctions_4_1_core.cpp qopenglfunctions_4_1_core.h

qopenglfunctions_4_2_compatibility.cpp qopenglfunctions_4_2_compatibility.h

qopenglfunctions_4_2_core.cpp qopenglfunctions_4_2_core.h

qopenglfunctions_4_3_compatibility.cpp qopenglfunctions_4_3_compatibility.h

qopenglfunctions_4_3_core.cpp qopenglfunctions_4_3_core.h

qopenglfunctions_4_4_compatibility.cpp qopenglfunctions_4_4_compatibility.h

qopenglfunctions_4_4_core.cpp qopenglfunctions_4_4_core.h

qopenglfunctions_4_5_compatibility.cpp qopenglfunctions_4_5_compatibility.h

qopenglfunctions_4_5_core.cpp qopenglfunctions_4_5_core.h

qopenglqueryhelper_p.h

qopengltimerquery.cpp qopengltimerquery.h

LIBRARIES

OpenGL::GL # 添加 OenGL 库

)

qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_vulkan

SOURCES

qvkconvenience.cpp qvkconvenience_p.h

LIBRARIES

OpenGL::GL # 添加 OenGL 库

)

if(QT_FEATURE_vulkan)

qt_internal_add_target_include_dirs_and_optionally_propagate(

OpenGL WrapVulkanHeaders::WrapVulkanHeaders)

endif()

qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_egl

SOURCES

qopenglcompositor.cpp qopenglcompositor_p.h

qopenglcompositorbackingstore.cpp qopenglcompositorbackingstore_p.h

LIBRARIES

OpenGL::GL # 添加 OenGL 库

)

qt_internal_create_tracepoints(OpenGL qtopengl.tracepoints)

qt_internal_add_docs(OpenGL

doc/qtopengl.qdocconf

)

终端窗口进入/Volumes/MacOS/Program/qt6.2.0/,执行:

cmake —build . —parallel

发现报错:

In file included from ../../../3rdparty/chromium/content/public/browser/browser_accessibility_state.h:12:

../../../3rdparty/chromium/content/public/browser/browser_context.h:21:10: fatal error: 'components/spellcheck/spellcheck_buildflags.h' file not found

#include "components/spellcheck/spellcheck_buildflags.h"

文件缺失:qt-6.2.0/qtwebengine/src/3rdparty/chromium/components/spellcheck/spellcheck_buildflags.h

手工创建该文件,写入内容

#define ENABLE_SPELLCHCEK 0

#define BUILDFLAG_INTERNAL_ENABLE_SPELLCHECK 0

修改文件browser_context.h第352行如下

//#if defined(TOOLKIT_QT) && BUILDFLAG(ENABLE_SPELLCHECK)

#if defined(TOOLKIT_QT)

// Inform about not working dictionary for given language

virtual void FailedToLoadDictionary(const std::string& language) = 0;

#endif

最后执行

cmake —build . —parallel

cmake --install .


http://www.ppmy.cn/devtools/112489.html

相关文章

避免 PyCharm 将该 Python 脚本作为测试运行

为了避免 PyCharm 将该 Python 脚本作为测试运行&#xff08;即 pytest 自动捕获&#xff09;&#xff0c;你可以做以下几步来确保该脚本作为普通的 Python 程序执行&#xff0c;而不是作为 pytest 运行。 解决方案&#xff1a; 1. 确保文件名不以 test_ 开头&#xff1a; P…

关于Acrel-1000DP分布式光伏监控系统在某制药公司21.35MW光伏10KV并网系统的应用探讨-安科瑞 蒋静

摘要&#xff1a;为实现“双碳目标”即中国明确提出的2030年“碳达峰”与2060年“碳中和”目标。推动节能减排、实现经济可持续发展&#xff0c;我国采取了一系列方案和行动。其中就包括能源绿色低碳转型行动&#xff1a;大力发展新能源&#xff0c;‌推动煤电节能降碳&#xf…

室内定位论文整理-20240911期

本文章由本人开发的论文总结AI Agent 。项目地址:https://github.com/zhangleino1/paper-summarizer 室内可见光通信与三维定位系统中空间调制性能评估 研究问题 本文探讨了基于混合可变-CAP的室内可见光通信(VLC)和三维定位系统的空间调制性能。通过深入研究其系统设计、工…

string xstring公司间的转换 XML ,常用类

类 &#xff1a; CL_ABAP_CODEPAGE CALL TRANSFORMATION ID SOURCE LS_APIXML DT_OUTPUT RESULT XML DATA(XMLSSS) . DATA(LV_CONVERT) CL_ABAP_CODEPAGE>CONVERT_FROM( XMLSSS ). *CL_ABAP_BROWSER>SHOW_HTML( HTML_STRING LV_CONVERT ). 类 &#xff1a; cl_http…

决策树基础概论

1. 概述 在机器学习领域&#xff0c;决策树&#xff08;Decision Tree&#xff09; 是一种高度直观且广泛应用的算法。它通过一系列简单的是/否问题&#xff0c;将复杂的决策过程分解为一棵树状结构&#xff0c;使得分类或回归问题的解决过程直观明了。决策树的最大特点在于可…

Python互相关统计学 地震学 心理学 数学物理和算法模型及数据科学应用

&#x1f3af;要点 同步时间序列数据地震时频域信息绘制地震噪声干涉图和频谱计算光变曲线和时滞互相关光变曲线并计算峰值和质心图像几何对应关系算法气候相关矩阵图测量麦克风间距离图像相似性量化及显着性统计测试个体同步性量化分析计算绘制有无泊松噪声的光曲线地震幅度和…

AI创作新手册:精通Prompt提示词的提问策略

文章目录 &#x1f34a;AI创作核心&#xff1a;提示词 Prompt 的重要性1. 什么是提示词工程&#xff1f;1.1 提示词的作用原理1.2 提示词工程师的薪资与行业前景1.3 提示词工程的适用性 2. 提示词的编写技巧3. 常见的提示词框架3.1 CO-STAR 框架3.2 BORKE 框架 4. 提示词的实际…

开源 XDR/SIEM 安全平台,附下载链接

最近&#xff0c;我在项目中接触到了一个开源安全平台——Wazuh。这款工具不仅提供了统一的 XDR 和 SIEM 保护&#xff0c;而且在应对多种环境&#xff08;如本地、虚拟化、容器化及云基础设施&#xff09;中的工作负载方面表现出色。这让我想起&#xff0c;在执行漏洞检测和配…

前端:HTML、CSS、JS、Vue

1 前端 内容概要 了解前端三件套(HTML、CSS、JS)在前端所起的作用掌握HTML标签的功能&#xff0c;掌握重要标签(a标签&#xff0c;form标签)了解CSS了解JS的基础语法掌握Vue的基础语法重点掌握Vue项目怎么启动项目掌握前后端分离是什么。前端做什么事情&#xff0c;后端做什么…

鸿蒙 - 判断手机号、身份证(正则表达式)

代码如下: import promptAction from ohos.promptAction;export class RegExpUtils {// 手机号正则字符串REGEXP_PHONE: string ((1[3|4|5|7|8][0-9]{9})$)// 身份证正则字符串REGEXP_DATE: string ((0[1-9])|(10|11|12))((0[1-9])|(1[0-9])|(2[0-9])|(30|31))REGEXP_CARD: …

修改docker的默认存储位置及镜像存储位置

前言 Docker 默认安装的情况下&#xff0c;会使用 /var/lib/docker/ 目录作为存储目录&#xff0c;用以存放拉取的镜像和创建的容器等。 不过由于此目录一般都位于系统盘&#xff0c;遇到系统盘比较小&#xff0c;而镜像和容器多了后就容易出问题&#xff0c;这里说明一下如何修…

【贪心算法】(二)贪心算法区间问题及进阶习题

贪心算法区间问题及进阶习题 贪心算法解决区间问题跳跃问题1. 跳跃游戏2. 跳跃游戏 Ⅱ 重叠区间问题3. 用最少数量的箭引爆气球4. 无重叠区间5. 划分字母区间6. 合并区间 其他问题7. 最大子序和8. 加油站9. 监控二叉树 贪心算法解决区间问题 跳跃问题 对于跳跃问题这一类问题&…

CTFShow-信息搜集

Web1&#xff1a; ​ 题目描述&#xff1a;开发注释未及时删除 。 ​ 打开题目后提示web1:where is flag? ​ ctrlu读取源码。 Web2&#xff1a; ​ 题目描述&#xff1a;js前台拦截 无效操作 ​ 打开题目后显示&#xff1a;无法查看源代码 ​ 右键无法用&#xff0c;…

DockerLinux安装DockerDocker基础

Linux软件安装 yum命令安装 通过yum命令安装软件,是直接把软件安装到Linux系统中 安装和卸载都比较麻烦,因为软件和系统是强关联的 Docker docker是一种容器技术,可以解决软件和系统强关联关系,使得软件的安装和卸载更方便,它可以将我们的应用以及依赖进行打包,制作出一个镜…

Chainlit集成Langchain并使用通义千问实现和数据库交互的网页对话应用(text2sql)

LangChain 简介 LangChain 是一个开源框架&#xff0c;设计用于开发和部署与语言模型&#xff08;如大型语言模型LLM&#xff09;交互的应用程序。它提供了一种简便的方法来构建基于自然语言处理&#xff08;NLP&#xff09;的系统&#xff0c;这些系统可以执行各种任务&#…

【VuePress 个人博客搭建】

个人博客搭建免服务器 一、安装 VuePress1、创建文件夹并进入该目录2、初始化项目3、安装VuePress4、在 package.json 中修改 scripts5、创建目录和配置文件6、创建第一篇文档Hello VuePress7、 运行项目二、部署1、新建github 仓库2、在 config.js 添加 base 路径配置:3、创建…

Linux网络——socket编程与UDP实现服务器与客户机通信

文章目录 端口号TCP/UDP网络字节序socket的常见APIUDP实现服务器与客户机通信服务器客户机运行效果如下 端口号 我们说即便是计算机网络&#xff0c;他们之间的通信也仍然是进程间通信 那么要如何在这么多计算机中&#xff0c;找到你想要的那个进程呢 在网络中标识的唯一的计…

机器学习TFIDF的情感分类文章

一.中文分词 当读者使用Python爬取了中文数据集之后&#xff0c;首先需要对数据集进行中文分词处理。由于英文中的词与词之间是采用空格关联的&#xff0c;按照空格可以直接划分词组&#xff0c;所以不需要进行分词处理&#xff0c;而中文汉字之间是紧密相连的&#xff0c;并且…

Rust 助力无服务器构筑云计算新引擎

引言 今年 Amazon Lambda 迎来了它的第一个十周年。在过去的十年里&#xff0c;无服务器架构改变了软件开发的方式&#xff0c;简化了应用程序的部署和扩展&#xff0c;成为云计算的新引擎。而在众多支持无服务器技术的编程语言中&#xff0c;Rust 以其卓越的安全性和高性能成…

【超星word下载】使用脚本下载的超星 word 文件,显示 Word 发现无法读取的内容

文章目录 前言一、问题描述二、解决方案 前言 在 下载超星文件时 时遇到的问题 &#xff08;学在西电&#xff09; 一、问题描述 二、解决方案 尝试将后缀改为 .doc / .docx尝试将后缀改为 .pdf&#xff0c;打开成功