Skip to content

Mac Build Instructions

sjanzou edited this page Apr 10, 2018 · 2 revisions

These instructions were written and tested in August 2017 with macOS Sierra 10.12.6, Xcode 8.3.3 with Command Line Developer Tools. They assume that you have at least installed Command Line Developer Tools on your Mac so that you can compile C++ projects from the command line in a terminal window. See this helpful blog for more about Xcode and Command Line Developer Tools. The builds are performed with OS X 10.9 support using the "-mmacosx-version-min=10.9" in both the CFLAGS and CXXFLAGS.

  • To install the Command Line Tools package in macOS Sierra, open a terminal window, and type the following command:

     xcode-select --install
    

    If Command Line Developer tools is not installed, you should see a message asking if you want to install them. Click Install: you do not need to get Xcode if you do not want the full Xcode package.

Decide where to store the SAM source code

The SAM project depends on wxWidgets libraries, which you can build in any directory. You will create a symbolic link and change the PATH environment to tell the SAM makefiles where to find the libraries.

The source code for the LK, WEX, SSC, and SAM projects should go in a single parent directory. If you already have a directory for your projects, you can use it, or you can create a new one specifically for SAM. These instructions use the following directory structure as an example:

.../sam_dev/wxWidgets-3.1.1
.../sam_dev/lk
.../sam_dev/wex
.../sam_dev/ssc
.../sam_dev/sam

The lk, wex, ssc, and sam directories should all be in one directory. The wxWidgets directory does not have to be in the same directory as those four.

Get the code repositories

  1. Download the wxWidgets 3.1.1 source code for Linux, OS X, etc. from https://www.wxwidgets.org/downloads/. The code repository is available in several zip formats. These instructions explain how to unzip the following file:

    wxWidgets-3.1.1.tar.bz2
    
  2. Clone the SAM code repositories:

    cd sam_dev
    git clone https://github.com/nrel/lk
    git clone https://github.com/nrel/wex
    git clone https://github.com/nrel/ssc
    git clone https://github.com/nrel/sam
    

    The git clone command automatically creates a directory for the repository, so you do not need to create a directory before you clone it. For example if you clone the lk repository into your sam_dev directory, Git will create an lk directory for the repository.

    Note. You can also download the repositories from GitHub as .zip files instead of cloning them. If you do that, be sure to extract them into directories named lk, wex, ssc, and sam so that the makefiles can find them.

Install wxWidgets 3.1.1

  1. Create a wxWidgets-3.1.1 directory, and extract the compressed file and tarball into it:

    bunzip2 –d wxWidgets-3.1.1.tar.bz2
    tar xvf wxWidgets-3.1.1.tar
    

    Note: You may be able to use tar xvjf without first running bunzip2 according to this article on thegeekstuff.

    You should now have a directory named wxWidgets-3.1.1 that contains several files and directories:

  2. Run the configure command in the sam/wxconfigure.macos64 file from the SAM repository. For example, if the file is in /sam_dev/sam directory in your home directory:

    cat ~/sam_dev/sam/wxconfigure.macos64 | bash
    

    This cat command reads the following command from the file and sends it to the shell to be interpreted to save you some typing:

    ./configure –prefix=$HOME/local/wx-3.1.1 --enable-stl=yes --enable-debug=no
    --enable-shared=no --with-cocoa --enable-macosx_arch=x86_64 --enable-unicode
    --enable-webview --with-cxx=11 --with-macosx-version-min=10.9  --with-libjpeg=builtin
    --with-libpng=builtin --with-regex=builtin --with-libtiff=builtin --with-zlib=builtin
    --with-expat=builtin --disable-qtkit --disable-mediactrl
    
    

    Note: The --disable-qtkit and --disable-mediactrl parameters are from the workarounds discussed in this wxWidgets issues ticket.

  3. Type the following make commands to install wxWidgets. The makefile will install wxWidgets in /Users/<user>/local/wx-3.1.1:

    make
    make install
    

    Note: You can use -j to increase the number of jobs and speed up the build, for example make -j2 or make -j8. See this discussion on Stackexchange.

    When the installation finishes, you should see the following message:

  4. Create a symbolic link to the wxWidgets installation directory.

    ln -s /Users/<USER>/local/wx-3.1.1/bin/wx-config /Users/<USER>/local/bin/wx-config-3
    
  5. Change the PATH environment variable to include the local/bin directory. To add it permanently, edit the .profile file in the home directory.

    export PATH=/Users/<USER>/local/bin:$PATH
    
  6. Test the installation:

    wx-config-3 --cflags
    

    If the installation was successful, you should see:

    -I/Users/<USER>/local/wx-3.1.1/lib/wx/include/osx_cocoa-unicode-static-3.1 -I/Users/<USER>/local/wx-3.1.1/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__
    

Build LK, WEX, SSC, and SAM Projects

  1. Build each project. In the following order:

    1. LK
    2. WEX
    3. SSC
    4. SAM

    The make file for each project is in the /build_osx directory.

    For example, from the sam_dev directory:

    cd lk/build_osx
    make
    cd ../../wex/build_osx
    make
    cd ../../ssc/build_osx
    make
    cd ../../SAM/build_osx
    make
    

Test the build

  1. To run SAM, typeopen SAM.app at the command line, or open a Finder window, go to the sam_dev/sam/build_osx directory, and double-clicking the SAM icon.

    Note. If you want to make a dmg file, you can do so by typing: bash makedmg.sh.

  2. When SAM starts, click Start a new project, and then click Photovoltaic (detailed) and Residential (distributed), and OK.

  3. On the Location and Resource page, click View data. That should open a DView window with data from the weather file selected on the Location and Resource page. DView is from WEX, so that confirms that WEX built correctly.

  4. Close the DView window.

  5. Click through the input pages to see that they display correctly. The user interface uses libraries from wxWidgets and WEX.

  6. Click Simulate in the bottom left corner of the SAM window. SAM should run a simulation and display results on the Results page. The results page also uses DView from WEX, and displays data generated by SSC.

  7. Click Macros (under the Simulate button), and click the Inverter Sizing Information button. Click Run macro at the top of the window. The macro should run and display a window with information about the inverter's performance. That confirms that LK (also from WEX) is working.