-
Notifications
You must be signed in to change notification settings - Fork 33
Mac Build Instructions
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 --installIf 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.
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.0
.../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.
-
Download the wxWidgets 3.1.0 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.0.tar.bz2 -
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/samThe
git clonecommand 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 thelkrepository into yoursam_devdirectory, Git will create anlkdirectory for the repository.Note. You can also download the repositories from GitHub as
.zipfiles instead of cloning them. If you do that, be sure to extract them into directories namedlk,wex,ssc, andsamso that the makefiles can find them.
-
Create a wxWidgets-3.1.0 directory, and extract the compressed file and tarball into it:
bunzip2 –d wxWidgets-3.1.0.tar.bz2 tar xvf wxWidgets-3.1.0.tarNote: You may be able to use
tar xvjfwithout first runningbunzip2according to this article on thegeekstuff.You should now have a directory named
wxWidgets-3.1.0that contains several files and directories:
-
Run the configure command in the
sam/wxconfigure.macos64file from the SAM repository. For example, if the file is in/sam_dev/samdirectory in your home directory:cat ~/sam_dev/sam/wxconfigure.macos64 | bashThis
catcommand 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.0 --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-mediactrlNote: The
--disable-qtkitand--disable-mediactrlparameters are from the workarounds discussed in this wxWidgets issues ticket. -
Type the following
makecommands to install wxWidgets. The makefile will install wxWidgets in/Users/<user>/local/wx-3.1.0:make make installNote: You can use
-jto increase the number of jobs and speed up the build, for examplemake -j2ormake -j8. See this discussion on Stackexchange.When the installation finishes, you should see the following message:
-
Create a symbolic link to the wxWidgets installation directory.
ln -s /Users/<USER>/local/wx-3.1.0/bin/wx-config /Users/<USER>/local/bin/wx-config-3 -
Change the PATH environment variable to include the
local/bindirectory. To add it permanently, edit the.profilefile in the home directory.export PATH=/Users/<USER>/local/bin:$PATH -
Test the installation:
wx-config-3 --cflagsIf the installation was successful, you should see:
-I/Users/<USER>/local/wx-3.1.0/lib/wx/include/osx_cocoa-unicode-static-3.1 -I/Users/<USER>/local/wx-3.1.0/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__
-
Build each project. In the following order:
- LK
- WEX
- SSC
- SAM
The make file for each project is in the
/build_osxdirectory.For example, from the
sam_devdirectory:cd lk/build_osx make cd ../../wex/build_osx make cd ../../ssc/build_osx make cd ../../SAM/build_osx make
-
To run SAM, type
open SAM.appat the command line, or open a Finder window, go to thesam_dev/sam/build_osxdirectory, and double-clicking the SAM icon.Note. If you want to make a dmg file, you can do so by typing:
bash makedmg.sh. -
When SAM starts, click Start a new project, and then click Photovoltaic (detailed) and Residential (distributed), and OK.
-
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.
-
Close the DView window.
-
Click through the input pages to see that they display correctly. The user interface uses libraries from wxWidgets and WEX.
-
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.
-
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.