ExRandom  3.0
Compiling all the examples
Back to Getting started. Forward to Code organization. Up to Contents.

If you're familiar with cmake, then use this to compile the example programs. On Linux and MacOSX, the commands are, for example,

mkdir BUILD
cd BUILD
cmake ..
make
make test
examples/simple_normal
etc.

For Windows they might be

mkdir BUILD
cd BUILD
cmake -G "Visual Studio 14" -A x64 ..
cmake --build . --config Release
cmake --build . --config Release --target RUN_TESTS
examples\Release\simple_normal
etc.

cmake will attempt to find Boost and MPFR for compiling the programs in the multiprec directory (see Multi-precision floating-point types). If necessary, define the MPFR_DIR path to point to where MPFR is installed. Other make targets which might be helpful are

  • clean, clean the build directory
  • doc, create the documentation using doxygen
  • install, install the headers and a cmake config file under ${CMAKE_INSTALL_PREFIX}
  • package_source, create tar and zip files of the distribution

If you install ExRandom, you can include it in another cmake project by

find_package (ExRandom REQUIRED)
# target_link_libraries sets the include path for the program,
# so it's not necessary to use include_directories.
# include_directories (${ExRandom_INCLUDE_DIRS})
add_executable (program source1.cpp source2.cpp)
target_link_libraries (program ${ExRandom_LIBRARIES})

Simple makefiles are provided to compile the programs in the examples directory. For Linux and MacOSX, use

cd examples
make
./simple_normal
etc.

On Windows, start, e.g., a "Visual Studio 14 command prompt", and type

cd examples
nmake /f makefile.vc
.\simple_normal
etc.
Back to Getting started. Forward to Code organization. Up to Contents.