Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

ctaggart/octh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust bindings for GNU Octave oct.h

GNU Octave has an external code interface, allowing you to add functionality. Octave functions can be built using the C++ oct.h. They get packaged into a library with the name of the new function and an .oct extension. See Getting Started with Oct-Files. This Rust crate exposes bindings to oct.h, so that you may build the Octave functions using Rust instead of C++.

Examples

use octh::*;

#[no_mangle]
pub extern "C" fn Ghelloworld (library: *const dynamic_library, relative: bool) -> *mut dld_function {
    let help = "Hello World Help String";
    dld_function_create(helloworld, library, "helloworld".into(), help.into(), relative)
}

extern "C" fn helloworld (argin: *const value_list, nargout: i32) -> value_list {
    let nargin = value_list_length(argin);
    println!("Hello World has {} input arguments and {} output arguments.", nargin, nargout);
    let mut argout = OctaveValueList::new(nargout);
    for i in 0..nargout {
        argout.set_value(i, Matrix::new().to_value());
    }
    argout.unwrap()
}

Building

  • Run cargo build. Octave must be installed. For development, I'm using Octave from Homebrew on both Mac and Linux. I installed it by running brew install octave. You will need to add these two environment variables, adjusted to your environment:
export OCTAVE_INCLUDE=/home/linuxbrew/.linuxbrew/Cellar/octave/5.1.0_8/include/octave-5.1.0
export OCTAVE_LIB=/home/linuxbrew/.linuxbrew/Cellar/octave/5.1.0_8/lib/octave/5.1.0

Issues

  • #10 build.rs is too platform specific
  • #36 macOS Catalina failing with __node_pointer defined multiple times

About

Rust bindings for GNU Octave oct.h

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published