### A.3 Standalone Programs

The libraries Octave itself uses, can be utilized in standalone applications. These applications then have access, for example, to the array and matrix classes as well as to all the Octave algorithms. The following C++ program, uses class Matrix from liboctave.a or liboctave.so.

         #include <iostream>
         #include <octave/oct.h>
         int
         main (void)
         {
           std::cout << "Hello Octave world!\n";
           int n = 2;
           Matrix a_matrix = Matrix (n, n);
           for (octave_idx_type i = 0; i < n; i++)
             {
               for (octave_idx_type j = 0; j < n; j++)
                 {
                   a_matrix (i, j) = (i + 1) * 10 + (j + 1);
                 }
             }
           std::cout << a_matrix;
           return 0;
         }

mkoctfile can then be used to build a standalone application with a command like

         $ mkoctfile --link-stand-alone hello.cc -o hello
         $ ./hello
         Hello Octave world!
           11 12
           21 22
         $

Note that the application `hello` will be dynamically linked against the octave libraries and any octave support libraries.