Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating multiple *.oct* files from a single *.cc* source file to interface a C library to Octave

Tags:

c++

octave

I have a C library that I want to use from within Octave. Following the tutorial, it seems straight forward: wrap the functions in C++ then mkoctfile them. The problem is: what if I want to have multiple functions definitions (wrappers) in a single source file?

In the mentioned tutorial it is stated

It should be noted that it is perfectly acceptable to have more than one DEFUN_DLD function in a source file. However, there must either be a symbolic link to the oct-file for each of the functions defined in the source code with the DEFUN_DLD macro or the autoload (Function Files) function should be used.

Then in the provided link:

Once Octave finds a file with a name that matches (the called function), the contents of the file are read. If it defines a single function, it is compiled and executed. See Script Files, for more information about how you can define more than one function in a single file.

In this second link, there is no info as to how to load a .oct file with multiple functions in it or how to generate multiple .oct files from a single source file. From what I've understood, the later is the correct approach. How can I do that?

like image 225
Pedro H. N. Vieira Avatar asked Jan 27 '26 15:01

Pedro H. N. Vieira


1 Answers

The point of the second link is that you don't load a .oct file with multiple functions in it - at least not from octave's perspective. That's what the symlinks are for - you have symbols A, B, and C in there? Make A.oct, B.oct, and C.oct symbolic links that point at that file and you can use them as if each contained only the symbol you care about.

like image 70
Carl Norum Avatar answered Jan 30 '26 04:01

Carl Norum