Original article is from
http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-ProgramsIf you just cope the code from the webpage. You will have a compiler error.
============================================
$ mkoctfile --link-stand-alone main.cc -o main
main.cc: In function 'int main()':
main.cc:13: error: 'row' was not declared in this scope
main.cc:13: error: 'column' was not declared in this scope
============================================
Modify row and column to i and j,
============================================
#include
#include
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 <>
{
for (octave_idx_type j = 0; j <>
{
a_matrix(i,j) = (i+1)*10 + (j+1);
}
}
std::cout <<>
return 0;
}
============================================
Then you should get the result,
============================================
$ mkoctfile --link-stand-alone hello.cc -o hello
$ ./hello
Hello Octave world!
11 12
21 22
$
============================================
If you have problem to use mkoctfile on Cygwin, you can refer to HERE.
No comments:
Post a Comment