Using Octave functions in C environment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Octave functions in C environment

HimajaK
Hi,
I intend to use existing Octave functions (written by me) from a C environment.
From what I have understood, .oct and .mex files are used to do the reverse. i.e., use C code in Octave environment.

Kindly help me with the solution

Regards,
Himaja


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Using Octave functions in C environment

Carlo de Falco-2

> On 7 Nov 2017, at 16:06, Himaja Kodati <[hidden email]> wrote:
>
> Hi,
> I intend to use existing Octave functions (written by me) from a C environment.
> From what I have understood, .oct and .mex files are used to do the reverse. i.e., use C code in Octave environment.
>
> Kindly help me with the solution
>
> Regards,
> Himaja

Hi,

Octave works well with C++ I'm not sure how to deal with C.
If C++ is OK for you, you have two options.

If you just need to use functons built into liboctave you can
create a standalone executable linking to liboctave as shown here:

http://hg.savannah.gnu.org/hgweb/octave/file/558de6a42ff7/examples/code/standalone.cc

and compile it with

mkoctfile --link-stand-alone

If you need to run interpreted m-files from within your application you can embed the
interpreter into your application as shown here:

http://hg.savannah.gnu.org/hgweb/octave/file/558de6a42ff7/examples/code/embedded.cc

please be aware that the syntax for embedding the interpreter has changed really a lot
lately so how to do it depends on the exact version of Octave you are working with

HTH,
c.





_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Using Octave functions in C environment

Carlo de Falco-2

> On 7 Nov 2017, at 19:12, Himaja Kodati <[hidden email]> wrote:
>
> Hi,
> Thank you for the prompt response.
> I get the following error while trying to run the example embedded.c in the 2nd link you provided.
>  error: octave/interpreter.h: No such file or directory
>
> I have found a documentation for octave/interpreter.h at
> http://octave.org/doxygen/4.0/d3/d7e/octave-interpreter_8h_source.html
>
> I'm not sure where to place this file. Kindly let me know how I can proceed.
> I am running octave 4.0.0 on Linux
> My octave binary resides at /usr/local/bin/octave
>
> Regards,
> Himaja

Please keep the mailing list in CC when replying, do not send private email.

You do not need to place that file anywhere it is already part of the Octave installation.

You can look up here: https://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

how to compile programs that link to Octave libraries and include Octave headers.

If you need further help you will need to provide more details about how you are trying to compile your code.

c.



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave