Cannot install fortran program on macOS via Terminal - macos

When I run make in the Terminal I get the following error:
gfortran: warning: couldn’t understand kern.osversion ‘15.6.0
gfortran -O1 -I.. -DFLUSH -c ../aocn2.f90
Any ideas on how to install fortran for macOS?

IMHO, the easiest way to install Fortran under macOS/OSX is via homebrew.
First, go to App Store and install Apple's Xcode. You can get to App Store by typing ⌘space and starting to type App Store and then hit Enter/Return once it guesses correctly. Xcode looks like this:
Then start a Terminal, using ⌘space Terminal Enter/Return and do the rest in Terminal.
Install the "Xcode command line tools":
xcode-select --install
Then install homebrew by going to homebrew website and copying and pasting the one-liner there.
Then install GCC ("GNU Compiler Collection") which includes gfortran:
brew install gcc
You will need to set your PATH to include /usr/local/bin which is where homebrew installs programs:
export PATH=/usr/local/bin:$PATH
You can now run:
gfortran someFile.for

Related

Xcode: Command not found

I have installed Xcode on my MacBook.
I checked that I have the XCode command line tool also installed as shown below:
I need to use Xcode command to install some dependencies, so I opened my terminal and run the command:
But I get Xcode: Command not found error. Why? How to get rid of this issue?
Okk, if you're trying to install the AWS ELastic beanstalk CLI (you're coming from EB CLI Installer on Github here)
then the line Xcode openssl zlib readline refers to all the packages that are prerequisites to the installation and not a command that you should run.
In short use:
brew install openssl
brew install zlib
brew install readline
And make sure Xcode is installed through which g++ if you get /usr/bin/g++
you're all set and you can proceed to the following steps

Installing GCC on macOS Catalina

I am on macOS Catalina and trying to install GCC by following the instructions here:
https://solarianprogrammer.com/2019/10/12/compiling-gcc-macos/
Everything seems to work fine until I try to configure. Then I get the following:
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
While trying to fix this I found the following:
MacOS "configure: error: cannot run C compiled programs"
However this answer requires going to the following directory:
/Library/Developer/CommandLineTools
The problem is I do not have CommandLineTools in /Library/Developer/ not even as a hidden file. Trying to fix this I found this
How to compile GCC on macOS Catalina?
but there is now answer here and I do not have nix and don't want to mess with it as it appears to not be very compatible with macOS Catalina. So the question is how can I run the configure?
Install GCC on MacOS
learn from above vedio,i use macOX 11.1, install gcc and g++ step:
"brew install gcc", after that, check install success by: "brew info gcc".
"cd /usr/local/bin"
"ls | grep 'gcc'" should see the gcc version you install before, like: gcc-10 or g++-10.
"ln -s gcc-10 gcc" make a symlink from your gcc version to gcc.
close terminal, and open again, input "gcc -v", should see it use gcc now.
If still use clang:
make sure you logout and login again.
use "where gcc" or "which gcc" to check your gcc symlink create success.
"echo $PATH", make sure "/usr/local/bin" show before "/usr/bin" on your PATH, if not, change it on your ~/.zshrc or ~/.bashrc
First you need to install the Command-Line tools.
$ xcode-select --install
Then you probably want to install the headers from a specific .pkg in Terminal:
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
(yours is 10.15, so):
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.15.pkg
After finishing the installation you should have the headers you need to compile with your GCC.
Probably not the elegant answer, but it worked. I was able to find the header files needed using $(xcrun --show-sdk-path) I then copied them all to /usr/local where the gcc location was expecting them to be. Now all works.

Make command taking too much time while installing gcc via brew

I have installed Xcode on my mac. However, installing gcc via the command brew install gcc is too time-consuming.
The issue with the brew installation is that make is taking hours to run and even then does not get completed.
That's how it goes. GCC is a big program, and takes a long time to build.
But! If you install the Xcode Command Line Tools, not just Xcode itself, then you can install gcc from the binary "bottle" file instead of building it yourself. Do this at the terminal:
sudo xcode-select --install
and say yes to the dialog that pops up. When it's finished, try doing brew install gcc again, and you should get a nice, quick binary installation.

how to install libX11 on OSx 10.9?

I am trying to install ROOT (cern.root.ch). When I run ./configure , I get a message that libX11 is missing and must be installed.
I did some research and found that I need to install
) XQuartz (I already have the latest version.)
) Command line tools in Xcode.
I tried installing Command Line Tools from apple's developer website. The installation goes through smoothly but how do I know whether it has been installed? I still get libX11 missing error with root's configure command.
I also tried xcode-select --install and it once went through smoothly and then later again gives error saying this package is no longer maintained - or something of that sort.
I understand I may have multiple installations... But I am still facing the problem of not having libX11 and not being able to install ROOT.
Thanks,
Hershal.
This link and the one referenced in it suggests you use homebrew (brew) to install it
$ ruby <(curl -fsS https://raw.github.com/mxcl/homebrew/go)
$ brew doctor
Remember to add the Homebrew directory to your PATH by adding the directory (found with brew --prefix) to your .bashrc, .zshrc or whatever shell file you’re using (.bashrc is the OS X default). We’ll also add the XQuartz binaries to the PATH in case anything needs them in the future.
export PATH=/usr/local/bin:/opt/X11/bin:$PATH
Start a new Terminal session to pick up the changes.
Now that Homebrew is installed, we can use it to install the required dependencies. Each may take some time as Homebrew generally compiles from source.
$ brew install gfortran # Fortran compiler
$ brew install python # Python interpreter
$ brew install pcre # Regular Expressions library
$ brew install fftw # Fast Fourier Transforms
$ brew install cmake # Cross-platform make
install root
$ brew tap homebrew/science
$ brew install --with-cocoa root
You don't say whether you have installed XCode as well as the commandline tools but I think you will need it

Installing openCV 2.4.2 on Mac OS X 10.9 (Mavericks)

I'm trying to install openCV 2.4.2 (not the newest version but stable version compatible with newer OS X according to several sources) on Mac OS X 10.9 (Mavericks). I have tried installing from source and using homebrew but neither works. I get the following error when I try installing it:
build Marieke$ make
[ 25%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.cpp.o
In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/src/precomp.cpp:1:
In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/src/precomp.hpp:2:
In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts.hpp:40:
/users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts_gtest.h:1657:13: fatal error:
'tr1/tuple' file not found
# include <tr1/tuple> // NOLINT
^
1 error generated.
make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.cpp.o] Error 1
make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
make: *** [all] Error 2
I don't know how to solve this and I have tried several things already (I do now have newest versions of Xcode, cmake, ffmpeg, faac, faad, qt, ...) so if anybody can help me, that would be much appreciated, thanks!
Run the following commands assuming you have brew installed.
brew tap homebrew/science
brew install opencv
Use macports. Once you install macports, just run
sudo port install opencv
at the command prompt.
This other stackoverflow question is mostly correct for how to start using the macports version of opencv in Xcode.
Here are some more up-to-date instructions for using the macports version of OpenCV from Xcode 5:
Create a new Xcode project as OS X Application -> Command Line Tool, etc.
Click the target in the upper left
Click the Build Settings tab
Scroll down to (or search for) the Search Paths section
Under User Header Search Paths add /opt/local/include
Click the Build Phases tab
Click Link Binary with Libraries
Choose the required libraries from /opt/local/lib
At least, add libopencv_core.dylib
If you want pre-set command-line arguments, go to Product -> Scheme -> Edit Scheme (⌘<)
Click the Run tab on the left
Click the Arguments tab
Enter arguments into Arguments Passed on Launch
Done!
You can try to install opencv from homebrew, I met the same problem with cmake in my 10.9 and finally I found the solution from Chris Muktar. Here are the steps:
Make sure xcode-select --install Xcode command line tools 5.0.1 are installed.
Install python using brew - brew install python.
pip update
pip install numpy
brew linkapps
Add export PYTHONPATH=/usr/local/Cellar/opencv/2.4.6.1/lib/python2.7/site-packages:$PYTHONPATH to .bash_profile in your home directory
brew install opencv
In the last step I came across the Error: No available formula for opencv. In this case, you should first run the command brew tap homebrew/science.
Good Luck
This may be related to the current issues with Qt on Mavericks.
See: https://github.com/mxcl/homebrew/pull/23793
I'd try installing the current patched homebrew keg for qt, and then installing opencv:
brew update
brew uninstall opencv
brew uninstall qt
brew install -v https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb --HEAD
brew install opencv
Caution to the wind: the qt build took me about an hour to complete
Thanks for the answers!
I ended up with the following solution: I added #define GTEST_USE_OWN_TR1_TUPLE 1 to ts_gtest.h. Probably not the prettiest solution but I don't need gtest for anything else so it works for me.
You could disable ts module in CMakeCache.txt file:
//Include opencv_ts module into the OpenCV build
BUILD_opencv_ts:BOOL=OFF
I mean that there is no reason to modify existing code.
I think you really need to do a configuration and that is it.
I tried your problems and I think steps are as follow:
open terminal in mac
in the terminal, check you have cmake and ccmake. If not, please type "brew install cmake"
go to your downloaded opencv folder, make a new folder by typing "mkdir build", then "cd build"
in this build folder, check you have gcc and g++ installed.
now, doing configuration by type "ccmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++", type "c" first for configuration then exit by "e" then "g" for generating!
you should be in terminal again now! then please type "make"
type "sudo make install", and now the opencv is installed, check it by type "brew list", and you should see the opencv there
type "brew linkapps"
do a test if you have python, by typing "import cv", and it should be working!

Resources