问题
I have two versions of Octave installed, version 3.6.4 installed via the package manager (Linux Mint Debian), and version 4.0.0 compiled from source. I also have numerous .oct files in a folder pointed to in an .octaverc file. My problem is that the version 4.0.0 cannot "see" these .oct files and if I try to call them the whole session crashes unless I recompile them under 4.0.0 with mkoctfile. However, doing this means that the version 3.6.4 cannot "see" them and trying to call them gives an error message
failed to load: liboctinterp.so.3: cannot open shared object file: No such file or directory
How can I get both versions to recognize my .oct functions without having to recompile them each time?
回答1:
I copy the answer from Mike and Olaf from the help mailinglist (crossposting http://octave.1599824.n4.nabble.com/Oct-files-run-in-Octave-version-3-6-4-or-4-0-0-but-not-both-td4672690.html)
Short answer: you can't.
The Octave library API and ABI change between releases. Octave 3.6 was liboct{ave,interp}.so.1, Octave 3.8 was liboct{ave,interp}.so.2, and 4.0 is liboct{ave,interp}.so.3. These libraries are not forwards or backwards compatible.
You can compile your oct-files in two (or three?) different paths with the wanted Octave version in the path.
If you want to install your files system-wide, a good candidate directory for the differently compiled oct-files seems to be
fullfile (OCTAVE_HOME (), "lib/octave/site/oct/", octave_config_info ("canonical_host_type"))
assuming OCTAVE_HOME () is different for each of your Octave versions. This directory seems to be in the path by default.
If not system-wide, you could check OCTAVE_VERSION () in your .octaverc and set the path differently for each version.
来源:https://stackoverflow.com/questions/32829531/oct-files-run-under-octave-3-6-4-or-4-0-0-but-not-both