On 22 Jun 2012, at 18:43, dragan mladenovic wrote:

> Hi all,
> 
> I'm trying to use octave from Visuall C++ (I'm writing Octave to .NET 
> wrapper). I'm new to c++ so please bear with me. My problem can be fount at 
> http://stackoverflow.com/questions/11100220/octave-c-and-vs2010.
>                                                                               
>                                                                               
>                                                                               
>                                               Thanks in advance.

Your code seems almost OK to me except for the fact that, 
at least on my system, the order of includes does matter, 
I tried the following:

    #include <iostream>
    #include <octave/oct.h>
    #include <octave/octave.h>
    #include <octave/parse.h>
    
    
    int main (int argc, char **argv)
    {
      
      if (octave_main (argc, argv, true))
        {
          ColumnVector NumRands (2);
          NumRands(0) = 10;
          NumRands(1) = 1;
          octave_value_list f_arg, f_ret;
          f_arg(0) = octave_value (NumRands);
          f_ret = feval ("rand", f_arg, 1);
          Matrix unis = f_ret(0).matrix_value ();
          std::cout << unis ;
        }
      else
        {
          error ("Octave interpreter initialization failed");
        }
      return 0;
    }


$ mkoctfile --link-stand-alone test.cc -o test
$ ./test -f -q 
 0.22969
 0.193488
 0.531824
 0.969092
 0.794625
 0.0462114
 0.115776
 0.725163
 0.379464
 0.716063

If this does not work for you probably the problem is not in the code but in 
what you are doing to build ...
c.



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to