Problems with the installation of control toolbox of octave in macOS big sur

I am trying to install the octave control toolbox in my macbook but something is going wrong.

My system

  • OS: Mac OS Big Sur (Intel ship) version 11.5.1
  • Octave version: 6.3.0
  • Installation method: brew install octave

Here is the message I receive when I try to install the toolbox:

>>pkg install -forge control
sh: gfortran: command not found
sh: gfortran: command not found
make: *** [slicotlibrary.a] Error 127
make: *** Waiting for unfinished jobs....
tar -xzf slicot.tar.gz
/usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -Wall -Wno-deprecated-declarations  __control_helper_functions__.cc
mkdir sltmp
mv slicot/src/*.f ./sltmp
mv slicot/src_aux/*.f ./sltmp
if [ "0" = "1" ]; then \
                echo "copy routines using DGGES"; \
                cp SB04OD.fortran ./sltmp/SB04OD.f; \
                cp SG03AD.fortran ./sltmp/SG03AD.f; \
                cp SG03BD.fortran ./sltmp/SG03BD.f; \
        fi;
cp AB08NX.fortran ./sltmp/AB08NX.f
cp AG08BY.fortran ./sltmp/AG08BY.f
cp SB01BY.fortran ./sltmp/SB01BY.f
cp SB01FY.fortran ./sltmp/SB01FY.f
cp SB06ND.fortran ./sltmp/SB06ND.f
cp TB01MD.fortran ./sltmp/TB01MD.f
cp TB01ND.fortran ./sltmp/TB01ND.f
cp TB01ZD.fortran ./sltmp/TB01ZD.f
cp TG04BX.fortran ./sltmp/TG04BX.f
cp ODLTZM.fortran ./sltmp/ODLTZM.f
cp makefile.slicot ./sltmp/makefile
cd sltmp; /usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -w -c MA02ID.f; rm MA02ID.f; /usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -c *.f;

error: pkg: error running 'make' for the control package.
error: called from
    configure_make at line 110 column 9
    install at line 196 column 7
    pkg at line 568 column 9

I tried to install/update GCC via brew command (thanks Kai)

but GCC is up to date and nothing changes in the above error message I receive. I am not familiar with software installation so any help will be of great value for me.

It looks like you don’t have gfortran or it is broken. Try brew reinstall gcc.

I did it but I receive the same error message when I try to install the control package.

Hmmm…
I don’t have a mac and cannot try myself. I also don’t know where homebrew installs gcc. But you could maybe try setting F77 to something like the following before installing the package:

setenv('F77', '/full/path/to/gfortran')

Does that help?

Dear Markus, thank you for your attention.
I did it but I receive the same error message when I try to instal the control package.

what do you get if you type

system("gfortran -v")

Here is the answer:

>> system("gfortran -v")
sh: gfortran: command not found
ans = 127

can you repeat this with the full path?

I am not familiar with software installation, I am not sure I understood your suggestion of full path. Are you thinking a command like the setenv above or should I run the command in a specific directory? To avoid error from my side may I suggest you to send me the line command I should run?

setenv("F77", "/full/path/to/gfortran")
system ("$F77 -v")

Where /full/path/to/gfortran is the full path to your gfortran executable.
It is probably something like /usr/local/bin/gfortran
On my system it is /usr/bin/gfortran and I got:

octave:1> setenv("F77", "/usr/bin/gfortran")
octave:2> system("$F77 -v")
Using built-in specs.
COLLECT_GCC=/usr/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC) 
ans = 0

Thanks for your help. Here is the answer:

>> setenv("F77", "/full/path/to/gfortran")
>> system("$F77 -v")
sh: /full/path/to/gfortran: No such file or directory
ans = 127

I verified the files in the /usr/bin directory and gfortran is not there. Lapack and openblas libraries were installed with brew from github.

I found the file gfortran in /usr/local/Cellar/gcc/11.2.0/bin.

As I wrote "/full/path/to/gfortran” should not be taken literally and means your actual path to gfortran.
If your gfortran is in /usr/local/Cellar/gcc/11.2.0/bin then you should use
/usr/local/Cellar/gcc/11.2.0/bin/gfortran

Thanks. Here is the answer:

>> setenv("F77", "/usr/local/Cellar/gcc/11.2.0/bin/gfortran")
>> system("$F77 -v")
Using built-in specs.
COLLECT_GCC=/usr/local/Cellar/gcc/11.2.0/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/11.2.0/libexec/gcc/x86_64-apple-darwin20/11.2.0/lto-wrapper
Target: x86_64-apple-darwin20
Configured with: ../configure --prefix=/usr/local/Cellar/gcc/11.2.0 --libdir=/usr/local/Cellar/gcc/11.2.0/lib/gcc/11 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran,d --program-suffix=-11 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-zstd=/usr/local/opt/zstd --with-pkgversion='Homebrew GCC 11.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues--enable-libphobos --build=x86_64-apple-darwin20 --with-system-zlib --disable-multilib --without-build-config --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.2.0)
ans = 0

OK, no do setenv(“F77”, “/usr/local/Cellar/gcc/11.2.0/bin/gfortran”) and try to install control package again.

>> setenv(“F77”, “/usr/local/Cellar/gcc/11.2.0/bin/gfortran”)
           ^
>> pkg install -forge control
ld: warning: directory not found for option '-L/usr/local/opt/gcc/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0'
ld: warning: directory not found for option '-L/usr/local/opt/gcc/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0/../../..'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [__control_slicot_functions__.oct] Error 1
tar -xzf slicot.tar.gz
/usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -Wall -Wno-deprecated-declarations  __control_helper_functions__.cc
mkdir sltmp
mv slicot/src/*.f ./sltmp
mv slicot/src_aux/*.f ./sltmp
if [ "1" = "1" ]; then \
                echo "copy routines using DGGES"; \
                cp SB04OD.fortran ./sltmp/SB04OD.f; \
                cp SG03AD.fortran ./sltmp/SG03AD.f; \
                cp SG03BD.fortran ./sltmp/SG03BD.f; \
        fi;
copy routines using DGGES
cp AB08NX.fortran ./sltmp/AB08NX.f
cp AG08BY.fortran ./sltmp/AG08BY.f
cp SB01BY.fortran ./sltmp/SB01BY.f
cp SB01FY.fortran ./sltmp/SB01FY.f
cp SB06ND.fortran ./sltmp/SB06ND.f
cp TB01MD.fortran ./sltmp/TB01MD.f
cp TB01ND.fortran ./sltmp/TB01ND.f
cp TB01ZD.fortran ./sltmp/TB01ZD.f
cp TG04BX.fortran ./sltmp/TG04BX.f
cp ODLTZM.fortran ./sltmp/ODLTZM.f
cp makefile.slicot ./sltmp/makefile
cd sltmp; /usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -w -c MA02ID.f; rm MA02ID.f; /usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -c *.f;
ar -rc slicotlibrary.a ./sltmp/*.o
rm -rf sltmp slicot
LDFLAGS="-F/usr/local/opt/qt@5/lib  -L/usr/local/opt/openblas/lib -lopenblas  -L/usr/local/opt/gcc/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0 -L/usr/local/opt/gcc/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0/../../.. -lgfortran -lquadmath -lm" \
    /usr/local/Cellar/octave/6.3.0/bin/mkoctfile-6.3.0 -Wall -Wno-deprecated-declarations  __control_slicot_functions__.cc common.cc slicotlibrary.a

error: pkg: error running 'make' for the control package.
error: called from
    configure_make at line 110 column 9
    install at line 196 column 7
    pkg at line 568 column 9

It looks like you have problems with your homebrew installation. Perhaps you could ask for help in MacOS/homebrew forums.

Hi Dimitri. Thanks a lot for your helping efforts and patience with my lack of knowledge in software installation.

Hi @Atrofino, congratulations you got gfortran to work thanks to @mmuetzel and @dasergatskov :slightly_smiling_face: Like I wrote in our discussion yesterday

the last error you receive is indeed a Homebrew problem and I work on it and report here, if it is resolved.

Hi Kai. I’ll be waiting for your feedback.

Sorry for letting you wait so long. However, there are no news on my request to the Homebrew either :sweat:

A dirty fix is to run the following two lines from the Terminal:

cd /usr/local/Cellar/gcc/11.2.0/lib/gcc/11/gcc/x86_64-apple-darwin20/
ln -s 11.2.0 11.1.0

After this, I could install and test the control package successfully on my macOS test system.