gfortran doesn't work after upgrading to El Capitan - fortran

I tried upgrading to El-Capitan and Xcode 7.0 and now gfortran doesn't work. Everytime I run gfortran, I get errors which google search doesn't seem to resolve so I'm asking stack overflow:
I'm trying to compile a minimal example program:
program hello
print *, "Hello World"
end program hello
When I run gfortran test.f
gfortran: warning: couldn’t understand kern.osversion ‘15.0.0
ld: library not found for -lgcc_s.10.4
collect2: error: ld returned 1 exit status
I'm not worried about the warning but the error of the ld is what's really bothering me. There's libgcc_s.10.4.tbd in the /usr/lib folder but it seems not be used by gfortran.
Can anyone help me resolve this as I would like to use gfortran for compiling some libraries?
MORE info: running gfortran -v outputs
gfortran: warning: couldn’t understand kern.osversion ‘15.0.0
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin12.2.0/4.8.0/lto-wrapper
Target: x86_64-apple-darwin12.2.0
Configured with: ../gcc-4.8-20120930/configure --enable languages=c++,fortran
Thread model: posix
gcc version 4.8.0 20120930 (experimental) (GCC)

The version of gfortran you have (4.8 installed into /usr/local) is not a version of GCC that apple would have distributed with Xcode (afaik they never made it to a version of GCC that new before switching to llvm, which has no Fortran front-end. The version of gcc distributed with Xcode 7 on el capitan identifies itself as:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.0.72)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
Your version came from somewhere else and is old enough to not know the x86_64-apple-darwin15.0.0 target. You'll need to update that compiler to get a working gfortran. Both macports and homebrew provide easy installations of various versions of gcc/gfortran on OS X el capitan, and I'd recommend using one of those to install gcc. Alternatively you can track down whatever you used to install gcc 4.8 before and see if they provide an update for el capitan.

Related

Issue compiling a piece of open source software written in C++ on MacOS Sierra

I am trying to install a piece of open source software (AB3P) on MacOS Sierra. When I issue the command make I get this error: ld: library not found for -lops. The make command issued before the error is thrown is: g++ -g -o make_wordSet make_wordSet.o -L./Library -lops -D_POSIX_C_SOURCE=199506L -lpthread
I have the latest version of MacOS Sierra and Xcode + the Xcode command line developer tools (as of this writing). In addition gcc is installed, the command gcc --version returns:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I am not sure how to approach the problem, any suggestions?
Get into Library folder, and make it first.
cd Library
make
There it will find the libops.a
On the updated version of the Ab3P as #ridoro1 mentioned, you need to make first NCBITextLib and edit the both Makefiles under Ab3P and also under Library.
First get into Library and make it. Then make Ab3P.
You need to download this library and compile it, then edit Makefile in the folder of this library and the Makefile in the lib folder inside it to point to NCBITextLib-master folder on your disk, after that You can compile the ABP3 library.

clang-800.0.42.1 and open mp

I'm running max os x 10.11.6 and want to include openmp in my programs, meaning compile with -fopenmp which is giving me the error:
clang: error: unsupported option '-fopenmp'
clan --version is giving me:
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
According to
https://clang-omp.github.io/
clang supports openmp from version 3.7 onwards.
My first question is how does "clang-800.0.42.1" relate to "clang 3.7", so do I actually have open mp support?
My second question is, according to this simple example:
http://blog.llvm.org/2015/05/openmp-support_22.html
I have to tell clang where the omp header files and libs are located as well as add the libs to DYLD_LIBRARY_PATH. But what are the files and libs exactly called and where can I find them? I'm running default xcode without any homebrew/special compiler stuff installed.
Thx for the help!

which gcc am I using?

I am attempting to compile a package on my Mac laptop and my Mac Mini desktop. It compiles successfully on the laptop, but not the mini (gives the following error: gcc: error: unrecognized command line option '-Xarch_x86_64'). Both machines are running OS X Yosemite (10.10.2). On both machines, when I type
which gcc
I get:
gcc: aliased to nocorrect gcc
(I don't know what this means) When I type
echo $PATH
I get:
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
This makes me think that if a gcc is found in /usr/local/bin, that's the one that will be my gcc. When I type
ls -l /usr/local/bin/gcc
I get:
/usr/local/bin/gcc -> /usr/local/bin/gcc-4.8
on both machines. However, when I type
gcc --version
on the Mini I get:
gcc (Homebrew gcc48 4.8.4) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and on the laptop I get:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
Which is the version installed by XCode. (This is what I get on both machines from /usr/bin/gcc --version)
How is the laptop using gcc 4.2 when the first gcc in my path is a symlink to gcc 4.8, and how do I make the mini do the same?
The nocorrect prefix is a zsh construct that will inhibit spelling correction.
It looks like you may have installed a specific gcc version with homebrew on the Mac Mini and you're using the system compiler (or rather, the one installed with XCode command line tools) on the laptop.
If you don't want to use the gcc installed with homebrew, you can just do:
brew unlink gcc
That will make the symlink go away and you'll use the next compiler. Which is hopefully the one you want.
When which gcc returns something like gcc: aliased to nocorrect gcc, the way to get the actual path would be to unalias foo, like this:
$ unalias gcc
$ which gcc
/usr/bin/gcc
This will remove the alias for the current shell, and you'll have to open up a new terminal or re-alias it yourself.
If you'd rather not do that, then you can use bash to determine the where the command is coming from:
$ bash -c 'which gcc'
/usr/bin/gcc

Eclipse /bin/sh: g++: command not found

I had to upgrade my gcc version to utilize the new C++11 standards. After following the instructions at http://ask.xmodulo.com/upgrade-gcc-centos.html . I started getting the error "/bin/sh: g++: command not found" when I try to build my project. How can I fix this? It looks like gcc installed fine by looking at the below output.
gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
G++ appears to be not installed. Find how to install gcc in your OS. After this, you have to make Eclipse find g++. I recommend to you, to install CDT plugins. They have many ready tools for C/C++ programming and it is fully compatible with gcc toolset.

The command line clang/clang++ doesn't work on MacBook Air 2012 Mid with OS X 10.8.5

Originally, I used clang++ with -std=c++11 compile my C++11 code, everything was OK. Recently, I updated the Xcode in AppStore, I compiled the SAME program in command line again, it doesn't work anymore, it shows errors like below:
/usr/include/c++/4.2.1/bits/stl_construct.h:81:38: error: no matching
constructor for initialization of
'std::basic_string'
::new(static_cast(__p)) T1(_value);
It seems the clang++ is using gcc's header files, apparently, gcc's version is very old. However, if I compile the same program by using Xcode, everything is fine.
It seems, at command line , the clang++ can't find the correct header files anymore.
More information, running command clang++ --version, following output:
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0 Thread model: posix
which clang++
/usr/bin/clang++
RESOLVED with option -stdlib=libc++