官术网_书友最值得收藏!

Setting up a Mac-based development platform

One important advantage of using OpenGL is the possibility of cross-compiling the same source code on different platforms. If you are planning to develop your application on a Mac platform, you can easily set up your machine for development using the upcoming steps. We assume that you have either Mac OS X 10.9 or higher installed. OpenGL updates are integrated into the system updates for Mac OS X through the graphics driver.

Installing Xcode and command-line tools

The Xcode development software from Apple provides developers with a comprehensive set of tools, which include an IDE, OpenGL headers, compilers, and debugging tools, to create native Mac applications. To simplify the process, we will compile our code using the command-line interface that shares most of the common features in Linux.

Getting ready

If you are using Mac OS X 10.9 or higher, you can download Xcode through the App Store shipped with Mac OS. Full installation support and instructions are available on the Apple Developer website (https://developer.apple.com/xcode/).

How to do it...

We can install the command-line tools in Xcode through the following steps:

  1. Search for the keyword Terminal in Spotlight and run Terminal.
    How to do it...
  2. Execute the following command in the terminal:
     xcode-select --install
    

    Note that if you have previously installed the command-line tools, an error stating "command-line are already installed" will appear. In this case, simply skip to step 4 to verify the installation.

  3. Click on the Install button to directly install the command-line tools. This will install basic compiling tools such as gcc and make for application development purposes (note that CMake needs to be installed separately).
  4. Finally, enter gcc --version to verify the installation.
    How to do it...

See also

If you encounter the command not found error or other similar issues, make sure that the command-line tools are installed successfully. Apple provides an extensive set of documentation, and more information on installing Xcode can be found at https://developer.apple.com/xcode.

Installing MacPorts and CMake

In this section, we outline the steps to install MacPorts, which greatly simplifies the subsequent setup steps, and CMake for Mac.

Getting ready

Similar to the Windows installation, you can download the binary distribution of CMake from http://www.cmake.org/cmake/resources/software.html and manually configure the command-line options. However, to simplify the installation and automate the configuration process, we highly recommend that you use MacPorts.

How to do it...

To install MacPorts, follow these steps:

  1. Download the MacPorts package installer for the corresponding version of Mac OS X (https://guide.macports.org/#installing.macports):
  2. Double-click on the package installer and follow the onscreen instructions.
    How to do it...
  3. Verify the installation in the terminal by typing in port version, which returns the version of MacPorts currently installed (Version: 2.3.3 in the preceding package).

To install CMake on Mac, follow these steps:

  1. Open the Terminal application.
  2. Execute the following command:
    sudo port install cmake +gui
    

To verify the installation, enter cmake –version to show the current version installed and enter cmake-gui to explore the GUI.

How to do it...

At this point, your Mac is configured for OpenGL development and is ready to compile your first OpenGL application. For those who have been more accustomed to GUIs, using the command-line interface in Mac can initially be an overwhelming experience. However, in the long run, it is a rewarding learning experience due to its overall simplicity. Command-line tools and interfaces are often more time-invariant compared to constantly evolving GUIs. At the end of the day, you can just copy and paste the same command lines, thereby saving precious time needed to consult new documentation every time a GUI changes.

主站蜘蛛池模板: 奉节县| 井冈山市| 凤翔县| 措勤县| 黑河市| 庐江县| 平定县| 柏乡县| 来宾市| 丹巴县| 南通市| 新巴尔虎左旗| 商河县| 图木舒克市| 社会| 荃湾区| 普宁市| 左权县| 漠河县| 兰坪| 西峡县| 梅河口市| 左贡县| 闸北区| 潞城市| 鄂尔多斯市| 墨玉县| 海盐县| 新化县| 隆昌县| 淳化县| 仁布县| 青海省| 沧州市| 临夏市| 诸暨市| 福鼎市| 会理县| 行唐县| 黔东| 香港 |