help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Integrating Octave with C/C++


From: SUMIT SARKAR
Subject: Integrating Octave with C/C++
Date: Sat, 31 Aug 2013 09:59:02 +0530

Hi... I am a beginner in using Octave...I have used Octave from command prompt and run *.m files with octave. But now I want to integrate Octave with C/C++ i.e. use the octave matrix and complex classes and its APIs from my C/C++ code. I am using QtCreator 5.1 with mingw 4.8 on windows 7 platform. I downloaded Octave 3.4.3 with gcc4.5.2. 

I installed octave in C drive and added the bin folder path to the environmental variable PATH. I included the path of the header files and linked the libraries.

The following is the piece of code I am trying to run.

     #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;
     }

The program builds successfully but has a run time error. When i debug it it shows the error of segmentation fault (in attatchment).

Please help...

Attachment: error.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]