Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code

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

Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code

JokerOne
Hi community,

despite the fact, that similiar questions were posed in the past in this list, I would like to
ask these questions once more, as I find the existing answers and posts quite confusing, sorry.
So maybe, you could help me to find out about the current situation:

1.) Are there any ways to compile an octave.m file to - say- c or c++ ? (I guess there are none, but maybe I am wrong?).

2.) Are there ways to call Octave functions from within a c (or c++) code?
A brief answer with some links to more information are very appreciated. Thx




Reply | Threaded
Open this post in threaded view
|

Re: Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code

tmacchant




----- Original Message -----

> From: JokerOne 
> To: [hidden email]
> Cc:
> Date: 2014/8/25, Mon 21:46
> Subject: Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code
>
> Hi community,
>
> despite the fact, that similiar questions were posed in the past in this
> list, I would like to
> ask these questions once more, as I find the existing answers and posts
> quite confusing, sorry.
> So maybe, you could help me to find out about the current situation:
>
> 1.) Are there any ways to compile an octave.m file to - say- c or c++ ? (I
> guess there are none, but maybe I am wrong?).

There were such attempts but no projects had been accomplished.


> 2.) Are there ways to call Octave functions from within a c (or c++) code?
> A brief answer with some links to more information are very appreciated. Thx
>
See the octave manual,

http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

From the paragrph:
"Note that the application standalone will be dynamically linked against the Octave libraries and any Octave support libraries. The above allows the Octave math libraries to be used by an application. It does not, however, allow the script files, oct-files, or builtin functions of Octave to be used by the application. To do that the Octave interpreter needs to be initialized first. An example of how to do this can then be seen in the code"

 (example code)
Tatsuro
>

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

Re: Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code

Richard Kirk
In reply to this post by JokerOne

On 25 Aug 2014, at 13:46, JokerOne wrote:


1.) Are there any ways to compile an octave.m file to - say- c or c++ ? (I
guess there are none, but maybe I am wrong?).

Mathematica has a good way of saving a function as C++ or Fortran. That's probably where you got the idea from. Matlab does not do this, and nor does Octave as far as I know.


2.) Are there ways to call Octave functions from within a c (or c++) code?
A brief answer with some links to more information are very appreciated. Thx

Not directly, as far as I know. I have a C++ imaging program where I can do processing in Octave, but I have made my program take files from Matlab, and not the other way around. I wanted to process images in the various motion picture formats, I got my program to read them, and then send them to Octave, and then send the results back the other way. You might be able to do do this.

If you tell us what you want to do, then this might help.

Cheers.
Richard Kirk

---
FilmLight Ltd, Artists House, 14-15 Manette Street, London W1D 4AP
Tel: +44 (0)20 7292 0400  Fax: +44 (0)20 7292 0401








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

Re: Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code

c.-2
In reply to this post by JokerOne

On 25 Aug 2014, at 14:46, JokerOne <[hidden email]> wrote:

> 1.) Are there any ways to compile an octave.m file to - say- c or c++ ? (I
> guess there are none, but maybe I am wrong?).
>

no.

> 2.) Are there ways to call Octave functions from within a c (or c++) code?
> A brief answer with some links to more information are very appreciated. Thx

yes. the easiest example is inside the octave source code distribution:
http://hg.savannah.gnu.org/hgweb/octave/file/bb0c5e182c12/examples/code/embedded.cc

there is a section in the manual about this:
https://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

c.


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

Re: Compile an Octave script to c or c++/ Embed Octave functions in a c (or c++) code

JokerOne
In reply to this post by JokerOne
Thanks for the answers everybody.

Richard asked for my particular aim with this issue: Basically, I am developing and testing data analysis procedures in Octave to be implemented in a device. So, when I am satisfied with a an analysis procedure this is handed over to my collegue to be implemendted in what I guess is close to c++. I have to admit, that I do not know the actual language, but I guess a c++ code or class or similiar should be of use.

The apparent idea was to save some time and work by either compile my code to c++ or ,vice versa, embed my code in c++.