Skip to content

Build Environments (Linux)

Mohammad Heidarinejad edited this page Jul 6, 2015 · 1 revision

#Build Environments

OpenStudio (1.4.0 or older)

For detailed information about the build environments, please, follow the instructions on the OpenStudio's repository on the github. This section provides a brief instructions for superbuild and additional resources for troubleshooting.

The process may take more than 2 hours for the first time that the user builds a new OpenStudio. When you have a build, updating the building takes usually less time.

  • Install EnergyPlus: Install the command line tools and EnergyPlus 8.1.

  • Install Core Development Tools: First ensure you have a set of basic development tools and core dependencies. From a terminal type the following command:

sudo apt-get install dpkg-dev subversion libncurses-dev cmake-curses-gui libqt4-dev libboost-all-dev ruby-dev ruby swig libxt-dev doxygen graphviz libbz2-dev
  • Install CMake: For Ubuntu 12, we recommend using the latest version of CMake, rather than the standard distribution. The following commands will allow you to download and build CMake 2.8.11.2:
wget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
tar -xzf cmake-2.8.11.2.tar.gz
rm cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2
./configure
make -j2
sudo make install
cd ..
rm -rf cmake-2.8.11.2
  • Optionally Install Dakota (Recommended; known as MD5): Install gfortran, ATLAS, and LAPACK
sudo apt-get install gfortran libatlas-base-dev liblapack-dev
  • Install Dakota (unknown as MD5). First time users, register here, then download the Dakota 5.4 source code distribution.
  • Returning users, can download from this link
  • Next, use the following commands to extract and build Dakota. The version that you need to download is the source code dakota-5.4-public.src.tar.gz.
tar -xzf dakota-5.4-public.src.tar.gz
rm dakota-5.4-public.src.tar.gz
cd dakota-5.4.0.src/
Add #include <stddef.h> to the top of ./dakota-5.4.0+.src/packages/teuchos/packages/teuchos/src
cd dakota
mkdir build
cd build
ccmake ..
Set CMAKE_INSTALL_PREFIX to /usr/local/dakota , then configure and generate (then, c for configure and “g” for generate)
export F77=gfortran
make -j2
sudo make install
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/dakota/lib' >> ~/.bashrc
cd ../..
rm -rf dakota-5.4.0.src/
  • Compiling: You have everything you need to compile OpenStudio using make. From a terminal, change to the directory where you want to locate the files related to OpenStudio. Check out the OpenStudio source code:

  • Clone the github develop branch:

git clone https://github.com/NREL/OpenStudio.git
  • The output is something similar to:
Cloning into 'OpenStudio'...
remote: Counting objects: 17388, done.
remote: Compressing objects: 100% (7043/7043), done.
remote: Total 17388 (delta 10356), reused 17171 (delta 10188)
Receiving objects: 100% (17388/17388), 94.99 MiB | 1.32 MiB/s, done.
Resolving deltas: 100% (10356/10356), done.
  • Change directories into the source code check the cloned repository:
cd OpenStudio
  • You should see the folders/files created from the github repository: cloned OpenStudio folder

  • Create a build directory for building with make,

mkdir build-make
  • Change to the build directory
cd build-make
  • Run cmake directly
cmake ../
  • Output is similar to:
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /usr/bin/qmake (found suitable version "4.8.1", minimum required is "4.6.0") 
-- Boost version: 1.46.1
-- Found the following Boost libraries:
--   filesystem

--   regex
--   program_options
--   system
--   thread
--   date_time
--   serialization
-- Found SWIG: /usr/bin/swig2.0 (found suitable version "2.0.4", minimum required is "1.3.40") 
-- Found Ruby: /usr/bin/ruby (found version "1.8.7") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Desktop/openstudio_compiled/OpenStudio/build-make
  • There will now be a makefile in the build directory. To build the complete OpenStudio project, type make. If you have a multicore machine, you can build in parallel using the -j option. For example, make -j8 runs with up to 8 threads. make help will show you the available targets if you do not want to build the entire project. We recommend leaving a core or two free to prevent your computer from freezing up during the make.
make -j2
  • Output (last part) is something similar to:
  -- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
  • Compiling After Initial Build: The initial compilation step builds OpenStudio as well as some of its larger dependencies. After the initial compilation you need build only the core OpenStudio project. The makefiles for this project are located under \build-make\OpenStudioCore-prefix\src\OpenStudioCore-build\.

  • The OpenStudio version translator relies on a configured file to determine the current version of OpenStudio. Currently, this file must be reconfigured each iteration to the most recent version. You can do this by pointing either the ccmake or cmake-gui tool to the OpenStudioCore build directory, setting the values for CMAKE_VERSION_BUILD, CMAKE_VERSION_MAJOR, CMAKE_VERSION_MINOR to the values in the current OpenStudio.idd file, and then choosing to configure and then generate makefiles.

  • First, make sure the repository is updated git status

  • In the repository CMakeLists.txt shows the version of the file. ccmakeList.txt

  • Go to the build-make directory, all of the folders are dependencies and core-openstudio. folder structure

  • The OpenStudio core is several layers down in the ruby folder:

OpenStudioCore-prefix/src/OpenStudioCore-build/Products
  • To make a package, you need to turn on CPACK_BINARY_DEB. You need to type ccmake in the build-make folder: DEB

  • When, you have turned on the DEB, you need to type c to configure and press g to generate. It is important to note that sometimes to go to the advanced page, you may need to press t to reach out to the DEB option.

  • After the DEB is on, you can make the DEB package. Type,

sudo make package
  • NOTE: it is very important to use sudo; otherwise, the build will fail.

Note 1

Builds are based on the machine you’re building on. For example:

  • 32bit linux = 32bit package
  • 64bit linux - 64bit package

Note 2

  • Make package basically look for the install commands and perform staging to add the exact folders. It also archives the version that does not need it. It is not just zipping the files. It requires to have ruby; it is not optional anymore.

OpenStudio (1.4.1 or higher)

For detailed information about the build environments, please, follow the instructions on the OpenStudio's repository on the github. This section provides a brief instructions for superbuild and additional resources for troubleshooting.

Note 1

In addition to the existing dependencies, you may need to install

sudo apt-get install dpkg-dev git libboost1.55-dev clang

Otherwise, you'll receive the following error message: libboost error message

Note 2

Sometimes during the building for the new version of the OpenStudio, there might be difficulties associated with the installation ruby 2.0. Basically, this is important to consider:

  • Ruby 1.9 should be the actual default one.
  • Ruby 2.0 should be also installed.

Therefore, when you type ls -al /usr/bin | grep ruby to see the existing version of ruby installed on your machine. Also, ruby --version, should tell you that ruby 1.9 is the default ruby. Here is what you should see:

Image of gitBuilding

If you do not see that ruby 1.9 as the default ruby, try to uninstall and install ruby 2.0 package.

sudo apt-get remove ruby2.0
sudo apt-get install ruby2.0

Also, if still the problem exists, ruby to find where ruby is installed on the system with:

which ruby

You should see:

/usr/bin/ruby

If you see that ruby is installed on /usr/local/bin or something similar. You should remove ruby and installed official ruby 2.0 package. Most probably, you can try to use

sudo apt-get -f install 

When you use ls -al /usr/bin | grep ruby, you should see the above version of ruby installed on your system. To make sure that your built environment has the updated symlinks for the default ruby 2.0, you need to make sure the ruby 2.0 remnants from /usr/local/bin including erb, gem, irb, rdoc, ri, ruby, and testrb executables are removed. Here is how you can remove the remnants:

cd /usr/local/bin
sudo rm -f erb gem irb rdoc ri ruby testrb

There should also some ruby 2.0 remnant folders and other locations. You need to check /usr/local/lib and /usr/local/share; then, just type sudo rm -rf anything ruby related.

Right now, you should be able to create the symlinks:

for i in erb gem irb rdoc ri ruby testrb; do
    sudo ln -s /usr/bin/$i''2.0 /usr/local/bin/$i
done

Update a Build

To update a build, follow the following instructions:

  • In the main branch, type git pull
  • To update the branch each time. In the main folder (one before the build-make) folder, type make - C build-make. This will update the main folder.
  • To update the core OpenStudio bindings. Type: make -C build-make/OpenStudioCore-prefix/src/OpenStudioCore-build
  • or when using ruby commands: ruby -I build-make/OpenStudioCode-prefix/src/OpenStudioCore-build/ruby
  • Then, type require 'openstudio'

Note:

  • When you are in the main directory, e.g. "build-make" directory, you need to type make since you are in the directory. If you are not in the "build-make", you need to type make -C build-make. Basically make -C \DIRECTORY_NAME runs the make for the given directory.

Build Node Bindings

OpenStudio enables to build different built environments. This section provides an overview to build node bindings. Here are the steps:

  • You need to make sure that new dependencies are installed.
sudo apt-get bison flex byacc
  • Type the following text to customize the build:
ccmake build-make
  • You should make sure the Build_V8_Bindings and Build_SWIG are ON. Here is a screenshot:

ccmake node bindings

  • After you have turned ON these two new items. Press c to configure. You should see a warning:

swig warning for the node bindings

  • Press e to exit the warning and then press c to reconfigure and g to generate.
  • If you would like to create a deb file for the installation, you need to turn ON, the CPACK_BINARY_DEB. Here is a screenshot:

swig warning for the node bindings

Note (Possible Error Messages)

If you do not turn on the BUILD_SWIG, you might get the following error message:

[ 14%] Built target ruby_OpenStudioUtilitiesTime
Scanning dependencies of target ruby_OpenStudioUtilitiesUnits
[ 14%] Building CXX object src/utilities/CMakeFiles/ruby_OpenStudioUtilitiesUnits.dir/ruby_OpenStudioUtilitiesUnits_wrap.cxx.o
Linking CXX shared module ../../Products/ruby/openstudioutilitiesunits.so
[ 14%] Built target ruby_OpenStudioUtilitiesUnits
[ 14%] Generating v8_OpenStudioUtilities_wrap.cxx
swig error : Unrecognized option -javascript
swig error : Unrecognized option -v8
Use 'swig -help' for available options.
make[5]: *** [src/utilities/v8_OpenStudioUtilities_wrap.cxx] Error 1
make[4]: *** [src/utilities/CMakeFiles/v8_OpenStudioUtilities.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [OpenStudioCore-prefix/src/OpenStudioCore-stamp/OpenStudioCore-build] Error 2
make[1]: *** [CMakeFiles/OpenStudioCore.dir/all] Error 2
make: *** [all] Error 2

This error message happens. Also, when you turn on the V8 and node bindings. Make sure, you have the dependencies sudo apt-get install bison flex byass; otherwise, you will receive these error messages:

config.status: creating preinst-swig
config.status: creating CCache/ccache_swig_config.h
config.status: creating Source/Include/swigconfig.h
config.status: executing depfiles commands
[ 79%] Performing build step for 'SWIG'
../../SWIG/Tools/config/ylwrap: line 113: yacc: command not found
make[4]: *** [CParse/parser.c] Error 1
make[3]: *** [source] Error 2
make[2]: *** [SWIG-prefix/src/SWIG-stamp/SWIG-build] Error 2
make[1]: *** [CMakeFiles/SWIG.dir/all] Error 2
make: *** [all] Error 2