Compile Qt For Mac



1) Ensure system is up-to-date

Before installation, ensure your macOS operating system is current. Select  menu -> 'System Preferences' -> 'Software Update' and check whether any OS updates are available. If so, install them first and only then proceed with the rest of this installation guide. In order to install QtCreator, you need to have a version of MacOS that is >= 10.13. If this is not possible for you, please reach out to the course staff ASAP.

The only cross compiler that I know of is GCC. I have actually used it on Linux to cross-compile for S/390 a while back, and also to cross-compile ARM code on a Power Mac (I used the instructions here to set it up). That said, I think that what you want is to cross-compile Windows x64 on a 32 bit virtual machine running Windows. This article is intended primarily for students leaning C for the first time on a Mac.It’s not a step-by-step tutorial on how to write and compile code in the applications described.

2) Install Xcode tools

Apple's developer tools are bundled as a part of Xcode. Installing Xcode provides the C++ compiler that is used by Qt Creator.

Mac Install Qt

To identify the correct version of Xcode to install, you need to know which OS you are running. Go to the  menu -> 'About This Mac' and read the macOS version number.

  • If you are running the macOS Catalina >= 10.15, you can install Xcode directly from App Store using the instructions below.
  • If your macOS is 10.14 or older, you need an older version of Xcode. In particular, MacOS 10.14 is compatible with Xcode version 11.3, and MacOS 10.13 is compatible with Xcode version 10.1. You can find older versions of Xcode at Apple Developer Downloads. Find the appropriate .xip file for your macOS version and then follow the second set of instructions below.

To install from App Store:

  • Select  menu - > 'App Store…'.
  • Search for Xcode. Download and install.

To install from Apple Developer Downloads: - Find and download the .xip file for the appropriate version of Xcode give your macOS version. - Once the file has downloaded, unzip the archive and install XCode. - Once Xcode has installed, you must drag the XCode icon into your Applications folder. After you have done this, open Xcode from the Applications folder by double-clicking on the icon and then follow the remaining instructions below.

Xcode is a very large app, so the download and stallation will take some time, and can be anywhere from 1-4 hours depending on your network connection speed. If your computer does not have enough space for Xcode, or if the download will take prohibitively long (more than 24 hours) due to the quality of your internet connection, reach out to Nick for alternate installation instructions.

3) Run Xcode once

After downloading Xcode, you have to actually launch the Xcode application one time to install its components.You can open Xcode using Spotlight (the magnifying glass at the top right of your screen) and typing in 'Xcode'.Click 'Agree' to accept the License Agreement and enter your password if prompted. Watch the progress bar 'Installing components…'. When it finishes, you may exit Xcode and do not need to launch it ever again for this course.

4) Download the Qt Creator installer

The Qt Creator official download site is https://www.qt.io/download-qt-installer.When you go to this site, it should detect that your computer is running MacOS and recommend the installer 'Qt Online Installer for Mac OS'. Click the green 'Download' button to download the installer.

5) Run the Qt Creator installer

The downloaded installer is named something like qt-unified-mac-version.dmg. Double-click to mount the disk image and launch the installer..

The graphical installer launches and walks you through a set of steps. For most steps, you can use the default settings and simply click 'Next' or 'Agree' to move on, with the following exceptions:

  • At the Qt Account step, you will have to create your own Qt Account.
  • At the Select Components step:
    • Select the highest-numbered Qt version. As of June 17, the latest release is Qt 5.15.0. Do not select any version labeled 'Preview' or 'Alpha' or 'Beta'.
    • IMPORTANT: You must also select the macOS kit component. Expand the 'Qt' triangle, then expand the triangle with Qt version number, then click the checkbox labeled 'macOS'. If you are tight on disk space, you can un-check every other checkbox except for 'macOS', as shown in the screenshot below.

6) Confirm installation

IMPORTANT: Follow the check step instructions to build and run our sample project that confirm your Qt Creator is installed properly and works correctly.

7) Configure settings (optional)

For a better experience, we suggest changing some of the default settings, see our recommended configuration settings.

Guide:

As a result of beslyric-for-x project development needs, began to try to develop Qt applications under Mac Os. After a successful attempt, record it and hope to help people with similar needs.

This article takes the development beslyric-for-x as an example to record the steps from downloading Virtual box to normal development and release.

This address: https://www.cnblogs.com/BensonLaur/p/9461589.html

Directory

  1. Install Mac Os with virtual Box
  2. Preparing for the development environment under MAC Os
  3. Preparing for the QT development environment
  4. Concrete Project Development Example: Beslyric-for-x
  5. QT release Software under Mac

1. Install Mac Os using Virtual Box

1) Download and install the latest version of Virtual Box

Download the latest version of Virtual Box:https://www.virtualbox.org/wiki/downloads according to the operating system platform you are currently using

2) Download Mac Os system

Before trying to download the Mac Os DMG installation image file to install, the initial attempt was not very smooth.

Finally find another path, there is an article directly to provide the installation of Mac Os 10.12 virtual Box vdisk file, the method is very practical measurement.

Article Address: https://www.cnblogs.com/liming2017/p/7566953.html

For

To prevent the article from failing, simply record the steps: '(name needs to be consistent, later steps required)

Mac Os Version Select 64-bit

Recommended allocation of 4 G deposit

Use an existing virtual hard disk file: Select the vmdk file that you downloaded and extracted from just 1

3, after the creation, click Settings, in the System settings panel, the number of processors changed to 2, the motherboard option to remove the 'floppy drive'

4, display option inside the video memory set to 128MB

5. Click OK to save the settings, then close the virtual machine, Run command prompt (CMD) as Administrator

6, enter your own installation directory, such as: CD 'C:Program filesoraclevirtualbox' into the VirtualBox directory, and then enter the following content

VBoxManage.exe modifyvm 'MacOS10.12'--cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbffvboxmanage setextradata ' MacOS10.12 'Vboxinternal/devices/efi/0/config/dmisystemproduct' 'imac11,3' Vboxmanage setextradata 'MacOS10.12' ' Vboxinternal/devices/efi/0/config/dmisystemversion ' 1.0 'Vboxmanage setextradata' MacOS10.12 ' vboxinternal/ Devices/efi/0/config/dmiboardproduct ' Iloveapple 'Vboxmanage setextradata' MacOS10.12 ' vboxinternal/devices/smc/0 /config/devicekey ' Ourhardworkbythesewordsguardedpleasedontsteal (c) applecomputerinc 'VBoxManage Setextradata' MacOS10.12 ' VBOXINTERNAL/DEVICES/SMC/0/CONFIG/GETKEYFROMREALSMC '1

VBoxManage.exe not recognized, may be different from the Shell version, you can try to add '. ' in front of the . vboxmanage.exe)

7, in virtual Box to launch the newly created VM, it should appear the graphical installation interface, step

2, prepare the development environment under the MAC

Mac install qt

Development needs to be developed under Mac, like Visual Studio under Windows and related development packages, tools for XCode and Command line tools need to be installed under Mac

Get development environment tools from official website

I would like to transfer the files on the Windows host and Mac VMS through the virtual machine sharing mechanism, but it seems that virtual Box support doesn't seem to be good enough to download directly from the virtual machine.

Mac development tool version seems to need to have a certain correspondence with the Mac version, from the official search XCode, Address: https://developer.apple.com/download/more/

Access requires an Apple ID, a registered one can be accessed (in the beginning with the domestic 126 mailbox received the mail is not normal registration, the second direct Gmail mailbox registration success).


According to Mac version number 10.12 I downloaded the Xcode 9.0.1 and Command line Tools (Mac OS 10.12) for Xcode 9.0.1, and eventually downloaded the original or downloaded high, prompting for Mac OS 10.12.6, And the system here is 10.12.1. Fortunately, the system automatically prompts to automatically upgrade to 10.12.6, in the App Store can be specific view and upgrade.

You may be able to directly try Xcode 9 and Command line Tools (Mac Os 10.12) for Xcode 9, and you might not need to upgrade your system later.


After downloading, install Xcode and Command line Tools (Xcode How to install I do not quite remember, as if the double-click directly installed, the installation is called Xcode.app; directly in the same directory of the compression package, after the configuration needs, I cut to/applications /xcode.app's location)


Other Preparations

1, install Brew, Brew is a package management tool under Mac, like apt under Debian/ubuntu. After installation, it is convenient to download the relevant components later:

installation command:

2. Using Brew to install related development tools

I'm not quite sure what tools I need later, but Pkg-config is a ffmpeg to use later, and here I downloaded Pkg-config and related tools.

3, in addition, the MAC by default hides the '.' File and other hidden files, viewing the file is a bit inconvenient, you can open Terminal enter the following command, restart effective

4, I heard that Xcode comes with git (?), I did not try not clear, because I started the MAC after the first thing is to download git, so you can install XCode input git to see if there is no corresponding instructions, no manual download

Download: https://www.git-scm.com/download/

5, the first use of the MAC is not suitable for, for example, can not find a direct cut operation, shortcut keys will not be used, it is recommended to see first, shortcut keys and cutting operations


3. Preparing for the QT development environment

Download the installation package under QT Mac and configure it accordingly

Download and install QT

Here choose QT Creator 5.7.1 corresponding Mac version file,: HTTP://DOWNLOAD.QT.IO/ARCHIVE/QT/5.7/5.7.1/

Select Download: qt-opensource-mac-x64-clang-5.7.1.dmg

After downloading, the general operation of the installation of Qt, after the installation of the configuration, can refer to this article, however, I seem to automatically detect the installation, I did not how to move the relevant configuration.


Problem Solving

1. After setting up QT project, qmake compile hint: Project error:could not resolve SDK path for ' MacOSX '

Solution: Terminal input as follows: (that is, here, I decided to move the Xcode.app just extracted to the directory/applications/xcode.app, feel applications is the system software is more conventional places)

Reference: http://www.renyiwei.com/archives/1326.html

2, Qmake hint similar: Application '/USR/BIN/GCC' is used by qmake, but '...' is configured in the kit.
Please update your kit or choose a mkspec for qmake that matches your target environment better.

Solution: Not resolved, not clear how to operate, directly right-click prompt, close it temporarily can continue to run

4, Concrete project Development example: Beslyric-for-x

Beslyric is a piece of open-source software designed specifically for NetEase cloud music Rolling lyrics (LRC lyrics), and the initial version is developed using the MIT protocol Open Source Interface library Soui, which supports the Windows platform. To meet the needs of other platforms (Linux and MAC) users, Beslyric-for-x is based on a cross-platform desktop application development architecture QT, which implements the development of Windows Linux (debianubuntu) Mac Os version.

Download Beslyric-for-x

Use git to download project code

Specific project Development

Specific development matters, can view project Reame Description: Https://github.com/BensonLaur/Beslyric-for-X


5. Use Qt release software under Mac

Qt Compile For Mac On Windows

Temporary not practiced, supplemented by the following

Level Two title

Content

Qt For Mac Download

Level Three title

Content


Compile Qt For Mac 10.13

Install Mac Os and install Qt development apps in Virtual Box