Search code examples
binaryoctave

How to use .oct binary as function


I am trying to use a .oct binary file compiled by someone else as a function.

The binary file is function.oct and the file I'm running in octave is 'test.m`. They both exist in the same directory.

In trying to call function.oct in test.m, I'm doing the following:

test.m

autoload('func', 'function.oct')
func(x, y)

This results in this error:

error: /Users/octavetest/xyz/st.oct: failed to load: dlopen(/octavetest/st.oct, 10): Library not loaded: /Applications/Octave-6.1.0.app/Contents/Resources/usr/opt/octave-octave-app@6.1.0/lib/octave/6.1.0/liboctinterp.8.dylib
  Referenced from: /Users/xyz/octavetest/st.oct
  Reason: image not found

How do I call the function from the compiled .oct file?


Solution

  • In general, you cannot use .oct binary files compiled by other users. OCT-files are linked with dependencies to the exact locations where Octave and other libraries are installed.

    error: /Users/octavetest/xyz/st.oct: failed to load: dlopen(/octavetest/st.oct, 10): Library not loaded: /Applications/Octave-6.1.0.app/Contents/Resources/usr/opt/octave-octave-app@6.1.0/lib/octave/6.1.0/liboctinterp.8.dylib
      Referenced from: /Users/xyz/octavetest/st.oct
      Reason: image not found
    

    You are looking at an OCT-file (st.oct, not function.oct) that was compiled against the Octave.app distribution of Octave, version 6.1.0, and that is the only Octave that it will run against.

    You'll need to get the source for that st OCT-file and recompile it in your Octave environment.

    Sorry.