Can not install gfortran via homebrew - fortran

I got this message when i tried to install gfortran.
~$ brew install gfortran
Error: No available formula for gfortran
GNU Fortran is now provided as part of GCC, and can be installed with:
brew install gcc
My question is how to install gfortran with homebrew or port?
or
If now GNU Fortran is a part of GCC How can i compile fortran code using gcc?
I'm not sure may be i've misunderstood something i remember that the last time i still can use gfortran to compile my code but now it doesn't work.
Further information:
when i use command brew list i still see that gfortran is there but can not use it.
Further information (latest):
ok, now i can use gfortran command but another problem come
~$ gfortran-4.9 hello.f
dyld: Library not loaded: /usr/local/lib/libcloog-isl.4.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/f951
Reason: image not found
gfortran-4.9: internal compiler error: Trace/BPT trap: 5 (program f951)
Abort trap: 6

Just do "brew install gcc" per the instructions. The gcc package contains gcc, g++, gfortran etc.

Related

MATLAB No supported compiler or SDK was found in mex_compile Linux

I had to downgrade my GCC to version 4.7 because I had this kind of problem when compiling matConvnet
Warning: You are using gcc version '5.4.0'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
So, I did the following steps to make GCC 4.7.0 the default compiler of my machine:
sudo apt-get install gcc-4.7
sudo rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.7 /usr/bin/gcc
However, when I try to compile Matconvnet again I had the following error:
Error using vl_compilenn>mex_compile (line 434)
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/glnxa64.html.
Error in vl_compilenn (line 387)
parfor i = 1:numel(horzcat(lib_src, mex_src))
What I missed in my procedure?
EDIT: I realized that the problem is with the g++ compiler
when I do the mex -setup C++ command in MATLAB I have this error:
Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/glnxa64.html.
When I do the which g++ command it returns me nothing. When I apt-get install g++ the following returns to me:
g++ is already the newest version (4:5.3.1-1ubuntu1).
What I can do to make MATLAB recognize my g++ compiler?
It's probably way to late for an answer, but when I had a similar problem, the following seemed to be the solution:
sudo apt-get install --reinstall gcc
sudo apt-get install --reinstall g++
Hope it helps everyone who stumbles upon this.

installing gfortran in cygwin: gfortran: cyglto_plugin.dll not found

I'm trying to get the gfortran compiler with cygwin. When attempting to compile a hello world program, I get the following error:
gfortran: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
To install the compiler, I used the cygwin setup and selected
gcc-fortran: GNU compiler collection
libgfortran3: GCC fortran runtime library
I also mistakenly selected the toolchains for mingw, even though I don't have the mingw compiler (as far as I'm aware). g++, which I installed awhile ago, works fine.
What do I need to do to compile/find the library?
It is because of the gcc and gfortran versions are not same, try checking that. If so, do the following
$ apt-cyg remove gcc-fortran
$ apt-cyg install gcc-fortran

Compile OpenMP programs with gcc compiler on OS X Yosemite

$ gcc 12.c -fopenmp
12.c:9:9: fatal error: 'omp.h' file not found
#include<omp.h>
^
1 error generated.
While compiling openMP programs I get the above error. I am using OS X Yosemite. I first tried by installing native gcc compiler by typing gcc in terminal and later downloaded Xcode too still I got the same error. Then I downloaded gcc through:
$ brew install gcc
Still I'm getting the same error. I did try changing the compiler path too still it shows:
$ which gcc
/usr/bin/gcc
So how do I compile programs with gcc?
EDIT: As of 13 Aug 2017 the --without-multilib option is no longer present in Homebrew and should not be used. The standard installation
brew install gcc
will provide a gcc installation that can be used to compile OpenMP programs. As below it will be installed into /usr/local/bin as gcc-<version>. The current gcc version available from Homebrew (as of writing) will install as gcc-8. You can compile programs with OpenMP support using it via
gcc-8 -fopenmp hello.c
Alternatively you could put an alias in your .bashrcfile as
alias gcc='gcc-8'
and then compile using
gcc -fopenmp hello.c
Note: I'm leaving the original post here in case it is useful to somebody.
The standard gcc available on OS X through XCode and Clang doesn't support OpenMP. To install the Homebrew version of gcc with OpenMP support you need to install it with
brew install gcc --without-multilib
or as pointed out by #Mark Setchell
brew reinstall gcc --without-multilib
This will install it to the /usr/local/bin directory. Homebrew will install it as gcc-<version> so as not to clobber the gcc bundled with XCode.
I finally did some research and I finally came across a solution here: <omp.h> library isn't found in the GCC version (4.2.1) in Mavericks.
I got a new gcc complier from http://hpc.sourceforge.net/
Then I placed a new executable folder by
$ sudo tar -xvf gcc-4.9-bin.tar -C /
Later I switched to it by
export PATH=/usr/local/bin:$PATH that seemed to do the trick!

Compiling a CGAL example program on Arch Linux with icpc

I want to compile an example program with CGAL 4.4 on Arch Linux with Intel Compiler.
But, on compiling this code, I got the following error:
$ icpc -o first_qp first_qp.cpp -lCGAL -I/usr/include/CGAL
The error message is here (pastebin)
What can I do?
# My box is up-to-date and the CGAL and boost library were already installed by pacman.
$ sudo pacman -Syu
$ sudo pacman -S cgal boost boost-libs
# I have already read an article about a similar question, but could not solve.
You should remove -I/usr/include/CGAL. It is not needed, and it confuses the compiler, which reads /usr/include/CGAL/gmp.h instead of /usr/include/gmp.h. Note that the recommended way to compile CGAL examples is with cmake (see the documentation), which handles all the flags for you.

Using g++ on OSX Lion, ld: unknown option: -no_compact_unwind

I followed the instructions at https://sites.google.com/site/dwhipp/tutorials/mac_compilers for OSX Lion and XCode 4.3 to use g++ on the command line, but when I run it I get this:
jeff~/Dropbox/cpp$ g++ hello.cpp
ld: unknown option: -no_compact_unwind
collect2: error: ld returned 1 exit status
If you want to use the latest version of GCC (4.7) by command line on Mac OS X Lion, I have a better solution.
Install MacPorts (you can download the source code and compile it or download the pkg installer):
http://www.macports.org/install.php
Installed MacPort, open the Terminal and type (you need the root password)
sudo port selfupdate
for updating the port tree. Then type
sudo port install gcc47 +universal
This command will install the GCC 4.7 compiler on your Mac (this compilation will take a lot of time, be patient). Now you have your GCC 4.7 compiler accessible by the command line under the name
gcc-mp-4.7
(use g++-mp-4.7for C++ compilation). You have also the new C++11 standard adding the option
g++-mp-4.7 -std=c++11