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.

#include <hpx/hpx_init.hpp>
#include <hpx/include/iostreams.hpp>

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

    return hpx::finalize();   // Initiate shutdown of the runtime system.

int main()
    return hpx::init();       // Initialize and run HPX.

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` -lhpx_component_iostreams -DHPX_APPLICATION_NAME=hello_world
[Important] Important

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

To test the program, type:

$ ./hello_world

which should print Hello HPX World! and exit.