HPX - High Performance ParalleX


How to Build HPX Applications with pkg-config

After you are done installing HPX, you should be able to build the following program. It prints Hello HPX World! on the locality you run it on.

// Including 'hpx/hpx_main.hpp' instead of the usual 'hpx/hpx_init.hpp' enables 
// to use the plain C-main below as the direct main HPX entry point.
#include <hpx/hpx_main.hpp>
#include <hpx/include/iostreams.hpp>

int main()
    // Say hello to the world!
    hpx::cout << "Hello World!\n" << hpx::flush;
    return 0;

Copy the text of this program into a file called hello_world.cpp.

Now, in the directory where you put hello_world.cpp, issue the following commands (where $HPX_LOCATION is the CMAKE_INSTALL_PREFIX you used while building HPX):

$ c++ -o hello_world hello_world.cpp `pkg-config --cflags --libs hpx_application` -liostreams -DHPX_APPLICATION_NAME=hello_world
[Important] Important

When using pkg-config with HPX, the pkg-config flags must go after the -o flag.

[Note] Note

If HPX was build in debug mode (cmake -DCMAKE_BUILD_TYPE=Debug) the pkg-config names have to be different. Instead of hpx_application or hpx_component you will have to use hpx_application_debug or hpx_component_debug. Moreover, all referenced HPX components need to have a appended 'd' suffix, e.g. instead of -liostreams you will need to specify -liostreamsd.

To test the program, type:

$ ./hello_world

which should print Hello World! and exit.