I am trying to get a MEX style extension library to work with Octave. We have a working MEX interface to our HW and would like to get it to also work with Octave.
I have no issues running mkoctfile with -L and -l to include the libraries and the compile-time link works just fine. And it looks like the .oct file is in order and there are no compile/link time errors.
The issue comes while running it in Octave and loading the extension. The runtime / dynamic linking fails.
The environment is Ubuntu 18.04. I have tried both the version of Octave (4.2.2) that is in the PPA's for Ubuntu 18.04 and the flatpak with Octave 5.1.0.
This works as follows with Matlab:
LD_LIBRARY_PATH=<correct directories to run> matlab
Then I call the .mexa64 file with and everything is fine.
Now trying the same method with octave:
LD_LIBRARY_PATH=<correct directories to run> octave
Call the test code and it fails with a missing symbol from a .so that is called.
I get a missing symbol that is a symbol in one of my .so's that is in the LD_LIBRARY_PATH. This is a top-level call, so the .oct file is calling this function that is in the .so file. The LD_LIBRARY_PATH has the directory to this .so.
If I do
LD_LIBRARY_PATH=<correct directories to run> flatpak run octave
This doesn't get anywhere as a bunch of boost libraries are missing as I'm sure the flatpak doesn't have the necessary libraries installed. Note that we use some less frequently used boost libraries in our .oct/.mex code. Actually, flatpak is probably the wrong way to do this if someone wants to extend Octave with their own very complicated set of libraries as flatpak will not have the libraries in the flatpak environment and it seems like it doesn't look at your current LD_LIBRARY_PATH, etc. Which of course is the case when you have your own SW interface to a new piece of HW. I have tried:
flatpak --env=LD_LIBRARY_PATTH=$LD_LIBRARY_PATTH:/usr/lib/x86_64-linux-gnu run org.octave.Octave
with the same result.
Any advice would be great as we would like to support Octave as well as Matlab.