0

I have a source code written in Fortran 90: sourcecode.f90

It needs Lapack libraries for compilation so, I compile the source code with this command:

gfortran -o executable.exe sourcecode.f90 -llapack

When I run this executable file in Ubuntu terminal using:

./executable.exe

everything runs fine. But when I try to run the same executable file in an Octave script with the line:

system("./executable.exe")

I get this error in the Octave command window:

./executable.exe: error while loading shared libraries: liblapack.so.3: cannot open shared object file: No such file or directory

Can anyone help me understand why this is happening? I need to run executable.exe in Octave for a larger code, but because of this, I'm unable to do so.

I'm using Ubuntu 18.04 with Octave 5.2.0.

  • 1
    Was Octave 5.2.0 installed as a snap? – steeldriver Apr 11 at 21:38
  • I installed Octave through flatpak. Does this make a difference? Because in another earlier system, I'd installed Octave through the gui software store, and it would run system('./executable.exe') just fine. – skirthy Apr 12 at 7:14
  • TBH I don't know much about containerisation but I suspect it might (i.e. not allowing access to shared libs outside of the container). There might be a workaround by copying the required libraries to somewhere in your home area and using LD_LIBRARY_PATH to make the linker search there (containers usually allow access to user's home) – steeldriver Apr 12 at 13:15
0

type the below commands

system('echo $SHELL');
system('echo $LD_LIBRARY_PATH');

and see if they look the same as typing echo in your Ubuntu terminals, if they are not the same, likely you started your octave from a launcher, which starts a non-interactive shell instead of an interactive shell (these cases, they have different rc files, see https://unix.stackexchange.com/a/170499/366890). you can at least run

system('LD_LIBRARY_PATH=/path/to/liblapack.so/folder ./executable.exe')

alternatively, find the correct rc file and add the path to LD_LIBRARYPATH in that environment.

| improve this answer | |
  • In Ubuntu terminal, I typed echo $SHELL and got /bin/bash as output. I typed echo $LD_LIBRARY_PATH and got no output. I got the same results when I ran them in Octave comand window using system ('echo $SHELL') and system('echo $LD_LIBRARY_PATH'). When I typed whereis liblapack.so in Ubuntu terminal, I got liblapack: /usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/liblapack.a. So in the Octave command window, I ran system ("LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ ./executable.exe") but got the same error message. – skirthy Apr 12 at 7:55
  • When I run octave in Ubuntu terminal, it says Command 'octave' not found even though I've installed octave through flatpak and can start the Octave gui from the applications launcher on the dock. Does this have anything to do with the present problem? – skirthy Apr 12 at 7:57
  • I tried adding the location of octave-gui and adding LD_LIBRARY_PATH in .bashrc in home folder, and in /etc/bash.bashrc with sudo privileges. These didn't help either. I then uninstalled octave and flatpak and reinstalled octave using sudo apt-get intall octave. Although the version I now have is older than earlier, the system("./executable.exe") command is now running fine without issues. Thanks for the help. – skirthy Apr 12 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.