Tutorials:Using ALPS in your projects

Revision as of 06:46, 15 March 2012 by Kota (talk | contribs)

Jump to: navigation, search

Using CMake

The ALPS libraries also provide an ALPS configuration file for CMake in /opt/alps/share/alps/ALPSConfig.cmake. Including that file will set all the configuration variables used when building ALPS. Additionally including the file /opt/alps/share/alps/UseALPS.cmake into your CMake file will automatically set the compiler and linker options to use ALPS. Here is an example CMakeLists.txt:

 cmake_minimum_required(VERSION 2.8)
 add_executable(hello hello.C)
 target_link_libraries(hello ${ALPS_LIBRARIES})

Note that NO_SYSTEM_ENVIRONMENT_PATH option in find_package is essential. Otherwise, the variables (compilers, etc) will be overwritten by the system default ones.

When running cmake, please specify the path where ALPS may be found:

 cmake -DCMAKE_INSTALL_PREFIX=/opt/alps /somewhere/to/your/source/code

The usual cmake commands (e.g. VERBOSE=1, for seeing what is actually done) apply.

Using make

If you can, please use cmake instead of make. The ALPS libraries come with a an include file for your Makefile that sets all the required include paths, link paths, and libraries to be linked to use ALPS. This include file is located at /opt/alps/share/alps/include.mk - or a similar location if you have installed ALPS at a different path than /opt/alps. An example Makefile using this include file is provided here in the C++ Ising model tutorial.