ug4
Building UG4

Before building ug4, you should make sure that you installed all necessary tools (Prerequisites and Recommended Tools) for your system. Beginners might also want to have a look at Some information about Shell and Linux.


Checkout ug4

Please follow the description at https://github.com/UG4/ughub to obtain a copy of UG4.


Bash Tools

For some helpful bash tools and completion, use the BASH Tools. If you are new to bash/Linux, please also try the bash prompt covered there.

For installing additional software like cmake, SuperLU, BLAS etc. see uginstall - Scripts for installation.


Run CMake

We are using CMake to do an out of source build. That means that the files created at compile time are in a different directory than the source. It is recommended to do the build in subdirectories of YOURUG4ROOT. Depending on the type of build, you can give them names, most common are build_release or build_debug, but some also like debug or release. When you are in the directory, you start cmake [DIR] where [DIR] is the directory where you find the CMakeLists.txt which says `project(P_UG4) inside. The following example is for a debug build:

  1. Open a terminal/shell window
  2. move to YOURUG4ROOT
  3. mkdir build_debug
  4. cd build_debug
  5. Generate Makefiles:

Note that there are several options that can be passed to CMake to change the build behaviour. You see always the current chosen setup when runnig cmake .. and you should see a list of options which you can change. In order to change an option run cmake again with the parameter -D<option>=<val>, where <option> is one of the enumerated options and <val> is one of the possible values for that option (< and > should of course not be typed). The last argument to cmake always has to be the path which you used when you called cmake the first time.

Note
To get more completions for the ug4 CMake parameters, use ugcmake.

Note that you only have to specify the variables which you want to change. All other variables will keep their values. Since in our example we want to do a debug build (hence the name build_debug) we need to enter cmake -DDEBUG=ON ... On the console in YOURUG4ROOT/build_debug.

As default ug is build for all supported world dimensions (Dim = 1,2,3). If you only need a special dimension (e.g. for code development) and you want to save compilation time, use the -DDIM option. Examples:

  • cmake -DDIM=ALL .. -> Builds all dimensions
  • cmake -DDIM=2 .. -> Builds only dimension 2
  • cmake -DDIM="2;3" .. -> Builds dimension 2 and 3, but not 1

For CMake Versions older than 2.8 you may be forced to explicitly specify, that the option DIM is passed as a string. So, please use: cmake -DDIM:STRING=2 .. etc.


Make

  1. move to YOURUG4ROOT/build_debug
  2. make

and your ug4 is being build. Common options for make are

  • -k: Don't stop at errors
  • -jN: Where N is the number of cores. We suggest to use no more than 4 and to keep an eye on memory consumption. There are some files in ug4/ugbase/bridge which need more than 1 GB RAM when being compiled, so you'll get stuck there.
  • VERBOSE=1: Do a "verbose" build, i.e., see what happens in detail (commands executed and their output which otherwise is suppressed).

With redirection of the output into a file, for later analysis, you would have e.g. (Bash syntax):

make VERBOSE=1 > static-build_make-verbose-output.txt 2>&1 

If everything went fine, you can move to YOURUG4ROOT/bin and start ugshell .