Hello world

Introduction

Intended audience

Process experts and system integrators who want to develop solutions based on the modeling of industrial continuous processes with the LIBPF® enabling technology.

Scope

Give a basic, step-by-step tutorial for your first “Hello, world!” program with LIBPF®.

Prerequisites

  1. Basic C++ skills

  2. properly configured Windows or Linux LIBPF® development workstation

  3. downloaded and installed the LIBPF® SDK.

Step-by-step

  1. Create a new C++ file with this content:

     #include <libpf/utility/diagnostic.h> // for the diagnostic macro
     #include <libpf/utility/Error.h> // for Error
     #include <libpf/Libpf.h> // for components, initializeLibpf and uninitializeLibpf
    
     static const int verbosityFile = 0;
     static const int verbosityInstance = 0;
    
     int main(int /* argc */, char * /*argv */ []) {
       const int verbosityLocal = 0;
       diagnostic(0, "Entered");
       try {
         // initializations
         initializeLibpf();
    
         diagnostic(0, "Hello, world !");
    
         uninitializeLibpf();
         return 0;
       } // try
       catch (Error &e) {
         uninitializeLibpf();
         e.append(CURRENT_FUNCTION);
         std::cerr << "****************************** Fatal LIBPF error! ******************************" << std::endl;
         std::cerr << e.message() << std::endl;
         return -1;
       } // catch
     } // main
    
  2. copy the supplied kernel.vcxproj to helloworld.vcxproj

  3. open the new Visual Studio project, add new C++ file to the project, see Step-by-step guide: adding new files to a LIBPF® project

  4. compile & run; expected output:

     LIBPF is correctly activated for site com.example_1.0 on this computer.
     main * Entered
     * ****************** LIBPF 01.00.2193 [2015/06/07 15:28:37] ******************
     * (C) Copyright 2004-2015 Paolo Greppi simevo s.r.l.
     * ****************************************************************************
     * All rights reserved; do not distribute without permission.
     * ****************************************************************************
    
     main * Hello, world !
    

Explanation

How to get on

  1. Proceed to the other tutorials