Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
1 result

README.macOS.md

Blame
  • README.macOS.md 18.96 KiB

    README.macOS.md - Building FLTK under Apple macOS

    Contents

    Introduction

    FLTK supports macOS version 10.3 Panther and above. At the time of writing (Jan. 2019), FLTK compiles and runs fine on the most recent macOS 10.14 Mojave.

    FLTK 1.4 supports the following build environments on the macOS platform:

    All environments will generate Unix style static libraries and macOS style app bundles.

    How to Build FLTK Using CMake and Xcode

    This option is best for users who like to develop their apps using Apple's Xcode IDE. There is no need to ever use a command line shell in this configuration.

    This option requires an Apple ID and the Administrator password.

    Prerequisites (CMake, Xcode)

    In order to build FLTK, you need to install CMake and Xcode.

    Xcode is Apple's IDE (Integrated Devloper Environment) and can be downloaded via the App Store. You will need an Apple ID and administrator right for this. Installing Xcode needs little to no user input, but will likely take well over an hour.

    "CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice."

    Please download and install the Mac OS X version of CMake from www.cmake.org. Download the .dmg file, click it, and when the Finder window opens, drag the CMake icon into the Applications folder.

    Downloading FLTK and Unpacking (CMake, Xcode)

    FLTK 1.4 is currently (as of Jan. 2019) only available as a source code repository via GitHub. You will need to clone the repository to check out the source code onto your machine. This has the great benefit that the source code can be updated later simply by telling git to pull the newest release.

    If you want to use Xcode to clone the FLTK GitHub repository, you will have to give Xcode access to your GitHub Account in the Xcode preferences. If you don't have a GitHub account, or don't want to share your credentials with Xcode, you can use still the command line git clone https://github.com/fltk/fltk.git fltk-1.4.git to ceck out the repo.

    Start Xcode. Select Source Control >> Clone... in the main menu.

    A dialog box will open with a search field and a list of repositories. Enter fltk/fltk in the search field. A list of matchin repositories appears. The first one should be named fltk and be owned by fltk. Select it and click Clone.

    A file chooser appears. Navigate to your home directory. The create a new folder named dev. Enter fltk-1.4.git in the Save As: field and click Clone, then Done in the previous dialog.

    The local copy of your repository can be updated by loading it into Xcode and selecting Source Control >> Pull... in the main menu.

    Configuring FLTK (CMake, Xcode)

    Launch CMake by pressing Command+Spacebar, the type CMake and press return. CMake should open with a large dialog box.

    The first input field is labeled with Where is the source code: . Click on Browse Source... and navigate to your home folder, then dev, then fltk-1.4.git. Click Open.

    The next input field is marked Where to build the binaries:. Click Browse Build... and navigate to your home folder, then dev, then fltk-1.4.git, then use New Folder to create a folder named build, and inside that, create a folder named Xcode. Click Open.

    The top two input fields should read

    /Users/your_name/dev/fltk-1.4.git

    and

    /Users/your_name/dev/fltk-1.4.git/build/Xcode

    Back in the CMake main window, click Configure, select Xcode as the generator and click Done. CMake will now analyse your system and find tools and dependencies. When done, the upper list field in CMake will show CMAKE, FLTK, and OPTION. Open the OPTION field and find the entries OPTION_USE_SYSTEM_LIBJPEG and OPTION_USE_SYSTEM_LIBPNG, and disable both for maximum compatibility with other macOS installation.

    Finally, click Generate to generate the Xcode IDE file.

    You may be wondering why we chose this rather involved way of creating the IDE files instead of just including the IDEs in the repo. Well, we did for the longest time, but creating new IDEs for every possible platform is quite involved. IDE file formats change, platforms change, and FLTK changes as well, and maintenance of the IDEs had become a nightmare. CMake on the other hand is very smart, knows about platforms and IDEs that we could never support manually, and usually needs to be run only once. Even when updating the FLTK source code later, CMake will be smart enough to update the build files as well.

    Building FLTK (CMake, Xcode)

    Now this is easy if all the previous steps were successful. If you are still in CMake, just click Open Project and CMake will launch XCode for you. If not, just launch XCode and open Macintosh HD⁩ ▸ ⁨Users⁩ ▸ your_name⁩ ▸ ⁨dev⁩ ▸ ⁨fltk-1.4.git⁩ ▸ ⁨build⁩ ▸ ⁨Xcode⁩ ▸ ⁨FLTK.xcodeproj.

    XCode may or may not ask to Autocreate Schemes. Click Automatically Create Schemes.

    In Xcode, set the 'active Scheme' to 'hello' or any other test program and press CMD+R to compile and run that application.

    Testing FLTK (CMake, Xcode)

    After a successful build, you can test FLTK's capabilities by choosing 'ALL_BUILD' as the 'active Scheme' and pressing CMD+B to build, then choosing 'demo' and pressing CMD+R to run the demo program.

    TODO: as of Jan 2019, compiling 'demo' will not compile any of the other demo programs. We really have to update the dependencies!

    Installing FLTK (CMake, Xcode)

    TODO: choosing the target 'INSTALL' will not work at this point because it requires root permission.

    Creating new Projects (CMake, Xcode)

    TODO: we still need to write a simple CMake file for creating a minimal cross platform app.

    How to Build FLTK Using CMake and make

    This option is best for users who like to develop their apps without using Apple's Xcode IDE, but like the advantages of CMake over autoconf. Users should be comfortable with using bash or tcsh in a terminal window.

    This option requires neither administrator rights, nor an Apple ID.

    Prerequisites (CMake, make)

    In order to build FLTK, you need to install CMake and the Xcode command line tools.

    "CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice."

    Please download and install the Mac OS X version of CMake from www.cmake.org. Download the .dmg file, click it, and when the Finder window opens, drag the CMake icon into the Applications folder.

    We will be using CMake from the command line. Please launch CMake and choose Tools > How to Install for Command Line Use and follow the instructions in the dialog box. If you have admin right, you can also use

    sudo ln -s /Applications/CMake.app/Contents/bin/cmake /usr/local/bin/cmake

    Installing the Xcode command line tools is pretty straight forward. Just enter this in your shell and follow the dialogs:

    xcode-select --install

    On older versions of macOS, you will have to install Xcode from the App Store and then install the command line tools from within Xcode.

    Downloading and Unpacking (CMake, make)

    Downloading FLTK is explained here.

    Configuring FLTK (CMake, make)

    Using you shell in the terminal, make sure that you are in the root directory of your FLTK source code tree.

    Create a directory where all FLTK binaries will be built:

    mkdir build
    cd build
    mkdir Makefile
    cd Makefile

    Now configure your FLTK installation:

    cmake -G "Unix Makefiles" \
        -D OPTION_USE_SYSTEM_LIBJPEG=Off \
        -D OPTION_USE_SYSTEM_ZLIB=Off \
        -D OPTION_USE_SYSTEM_LIBPNG=Off \
        ../..

    CMake runs a number of tests to find external headers, libraries, and tools. The configuration summary should not show any errors. You can now continue to build FLTK.