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

news/2024/9/19 1:12:35/ 标签: 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/news/1526790.html

相关文章

深入理解Go语言中的接口定义与使用

在Go语言的编程实践中&#xff0c;接口&#xff08;Interface&#xff09; 是一个强大而灵活的特性&#xff0c;它允许我们定义一组方法&#xff0c;而不需要指定这些方法的具体实现。通过接口&#xff0c;我们可以将不同类型的值组合在一起&#xff0c;只要它们实现了接口中定…

Docker | 轻松管理容器:Portainer安装与使用指南

引言 在Docker的世界中&#xff0c;管理容器、镜像、网络和卷可能会变得复杂&#xff0c;特别是当项目规模扩大时。幸运的是&#xff0c;Portainer提供了一个简单而强大的可视化界面来管理Docker环境。本文将带你了解如何安装和使用Portainer&#xff0c;让你的容器管理变得更…

策略路由与路由策略的区别

&#x1f423;个人主页 可惜已不在 &#x1f424;这篇在这个专栏 华为_可惜已不在的博客-CSDN博客 &#x1f425;有用的话就留下一个三连吧&#x1f63c; 目录 一、主体不同 二、方式不同 三、规则不同 四、定义和基本概念 一、主体不同 1、路由策略&#xff1a;是为了改…

[图解]强化自测题解析-总纲(一)02 抵制建模的心态

1 00:00:00,530 --> 00:00:02,270 今天我们来看 2 00:00:02,590 --> 00:00:06,270 强化自测题&#xff0c;总纲一的第二道题 3 00:00:07,260 --> 00:00:09,260 抵制建模的心态的题目 4 00:00:11,250 --> 00:00:11,860 单选题 5 00:00:13,430 --> 00:00:14,9…

【排序算法】之基数排序

一、算法介绍 基数排序是一种非比较型整数排序算法&#xff0c;其原理是将整数按低位到高位或者高位到低位的顺序&#xff0c;依次根据每一位的数值进行排序。通常情况下&#xff0c;基数排序会使用桶排序来处理每一位上的数值。 实现方法主要有如下&#xff1a; 最高位优先(…

基于鸿蒙API10的RTSP播放器(九:进度总结)

一、前言 基于鸿蒙API10和三方库ijkpalyer2.0.4&#xff0c;实现RTSP流的流畅播放&#xff0c;支持H.264和H.265硬编码&#xff0c;既可以在基于X86的模拟机上运行&#xff0c;也可以在基于armabi-v7a的真机上运行。 二、已实现功能 视频画面尺寸调整&#xff08;2:1比例&am…

小米,B站网络安全岗位笔试题目+答案

《网安面试指南》http://mp.weixin.qq.com/s?__bizMzkwNjY1Mzc0Nw&mid2247484339&idx1&sn356300f169de74e7a778b04bfbbbd0ab&chksmc0e47aeff793f3f9a5f7abcfa57695e8944e52bca2de2c7a3eb1aecb3c1e6b9cb6abe509d51f&scene21#wechat_redirect 《Java代码审…

redis基本数据结构-set

文章目录 1. set的基本介绍1.1. set底层结构之hash表的简单介绍1.2. 常用命令 2. 常见的业务场景2.1. 标签系统2.2. 社交网络好友关系 1. set的基本介绍 参考链接&#xff1a;https://mp.weixin.qq.com/s/srkd73bS2n3mjIADLVg72A redis 的 set 数据结构是一个无序的集合&#…

CSS 图片廊:打造精美视觉体验

CSS 图片廊&#xff1a;打造精美视觉体验 随着互联网技术的发展&#xff0c;网页设计越来越注重用户体验和视觉效果的呈现。CSS&#xff08;层叠样式表&#xff09;作为网页设计的重要工具&#xff0c;能够帮助开发者创建出既美观又实用的图片展示效果。本文将详细介绍如何使用…

html+css+js网页设计 旅游 龙门石窟4个页面

htmlcssjs网页设计 旅游 龙门石窟4个页面 网页作品代码简单&#xff0c;可使用任意HTML辑软件&#xff08;如&#xff1a;Dreamweaver、HBuilder、Vscode 、Sublime 、Webstorm、Text 、Notepad 等任意html编辑软件进行运行及修改编辑等操作&#xff09;。 获取源码 1&#…

学习笔记(一)

前言 一、对象 1、由类建模而成&#xff0c;是消息、数据和行为的组合 2、可以接收和发送消息&#xff0c;并利用消息进行彼此的交互。消息要包含传送给对象接收的信息 3、类的实例化&#xff1a;把类转换为对象的过程叫类的实例化。 4、对象的特性 (1) 对象有状态&#…

关于HarmonyOS的学习

day33 一、模块化 1.node模块化 let listMode require(./modules/list)let {index, tab} require(./modules/tab) ​// console.log(listMode)// console.log(tabMode) ​// console.log(listMode.index)// console.log(tabMode.index) ​// listMode.list() ​// console.…

istio中如何使用serviceentry引入外部服务

假设需要引入一个外部服务&#xff0c;外部服务ip为10.10.102.90&#xff0c;端口为32033. 引入到istio中后&#xff0c;我想通过域名gindemo.test.ch:9090来访问这个服务。 serviceentry yaml内容如下&#xff1a; apiVersion: networking.istio.io/v1beta1 kind: ServiceEn…

面向对象程序设计之模板进阶(C++)

在之前我出过一篇博客介绍了模版的初阶:面向对象程序设计(C)模版初阶&#xff0c;接下来我们将进行模版的进阶学习&#xff0c;介绍关于更多模版的知识 1.非类型模版参数 模板参数分类类型形参与非类型形参 类型形参即&#xff1a;出现在模板参数列表中&#xff0c;跟在class或…

ubuntu服务器版NVIDIA驱动失效解决方案

ubuntu服务器版NVIDIA驱动失效解决方案 1. 问题描述2. 解决方法--卸载并重新安装最新版显卡驱动cudacudnn2.1 卸载显卡驱动2.2 重新安装最新版显卡驱动cudacudnn2.2.1 显卡驱动2.2.2 cuda2.2.3 cuda安装cudnn 1. 问题描述 在终端输入nvidia-smi&#xff0c;输出如下&#xff1…

Leetcode 每日一题:Evaluate Division

写在前面 今天依旧是一道来自图论的题目&#xff0c;而今天这道题目的难度也是相对于前面分享过的题目中难度最大的一种。题主在第一次做这道题的时候根本没有反应过来这道题目可以转化为 图 来解决。而这道题目将一个 二维数组的乘除 运算转化为 图论 的过程需要一定的数学思…

企业组织韧性 Organizational Resilience(1990-2022年)

企业组织韧性&#xff08;Organizational Resilience&#xff09;是指企业在面对市场危机、经营挫折或环境变化时&#xff0c;能够迅速调整策略、适应变化&#xff0c;并从中恢复和成长的能力。 在VUCA&#xff08;波动性、不确定性、复杂性、模糊性&#xff09;情境下&#x…

King3399 SDK编译简明教程

该文章仅供参考&#xff0c;编写人不对任何实验设备、人员及测量结果负责&#xff01;&#xff01;&#xff01; 0 引言 文章主要介绍King3399&#xff08;瑞芯微rk3399开发板&#xff0c;荣品&#xff09;官方SDK编译过程&#xff0c;涉及环境配置、补丁以及编译过程中注意事…

Linux 基础入门操作-实验一 GCC使用

Linux 基础入门 前言 1 串口登录 本次登录可以采用串口登录&#xff0c;用usb线接入到系统&#xff0c;利用串口平台进行登录&#xff1b; 2 网口登录 2.1 路由器转接 电脑和开发板都接入路由器&#xff0c;路由器自动分开ip地址&#xff1b; 利用ipscan这个软件&#xf…

查看TCP/UDP网络连接通信情况

绪论​ “宿命论是那些缺乏意志力的弱者的借口。 ——罗曼&#xff0e;罗兰” 话不多说安全带系好&#xff0c;发车啦&#xff08;建议电脑观看&#xff09;。 主要使用&#xff1a; nestat -nltp n 拒绝显示别名&#xff0c;能显示数字的全部转化成数字l 仅列出有在 Listen (…