gfortran is not working on Mac OS X 10.9 (Mavericks) - osx-mavericks

Recently, I updated my OS X to 10.9 (Mavericks); unfortunately, gfortran stops working although I updated Xcode command line to 5.1.1 for OS X Mavericks. Similar question has been asked sometime ago, here, but I don't think so the issue is sorted out.
here is what I did:
first I removed the existing gfortran
bash-3.2$ sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran
Then I downloaded gfortran-4.9-bin.tar, and unzip it and installed successfully
bash-3.2$ gunzip gfortran-4.9-bin.tar
bash-3.2$ sudo tar xvf gfortran-4.9-bin.tar -C /
bash-3.2$ which gfortran
/usr/local/bin/gfortran
but when I start running my codes , I got the following errors, e.g.
bash-3.2$ gfortran boolean1.f90
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I would be immensely grateful if anyone could guide me to solve this problem.

Just for the record. I suggest to install gfortran from packages that are available from here:
https://gcc.gnu.org/wiki/GFortran
macOS installer can be found here: http://coudert.name/software/gfortran-6.3-Sierra.dmg
Just install most recent release (using dmg file) and everything should be fine
! fort_sample.f90
program main
write (*,*) 'Hello'
stop
end
Compilation and execution goes smooth
> gfortran -o fort_sample fort_sample.f90
> ./fort_sample
Hello

Related

gfortran 12.2.0 not working on M1 Macbook Air with MacOS Ventura 13.1-arm64

gfortran does not work on my M1 Macbook Air with MacOS Ventura 13.1-arm64
When I try to compile any program, e.g.
program main
print *, "Hello world."
end program main
I get the following error message:
(base) BL#MacBook-Air ~ % gfortran hello.f95 -o hello
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
Only gfortran seems to give an error; I can compile an equivalent C program using gcc just fine.
I tried a few things:
Updated from Ventura 13.0 to 13.1,
Used homebrew to update gcc from the older version which was installed
Unlinked the homebrew version and installed gfortran using https://github.com/fxcoudert/gfortran-for-macOS
But none of these made any difference.
I have the latest version of Xcode installed, so the command line tools are present.
Some details about my setup now:
Xcode is installed, Version 14.2 (14C18)
(base) BL#MacBook-Air ~ % which gfortran
/usr/local/bin/gfortran
(base) BL#MacBook-Air ~ % which gcc
/usr/bin/gcc
(base) BL#MacBook-Air ~ % which ld
/usr/bin/ld
Somewhere somebody suggested including a link, but that gave another problem:
(base) BL#MacBook-Air ~ % gfortran hello.f95 -o hello -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
So there seems to be both a linking problem and a problem with missing support for the M1 chip.
Any suggestions on how to solve this?
I started to suspect that the SDK which I linked to was outdated. I searched for "SDKs" on my disk and found a version which looked newer. So I changed the link to this:
-L/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
Now gfortran seems to compile as expected.

Can't compile fortran on MacOS Monterey: ld: unsupported tapi file type '!tapi-tbd' in YAML file

I am facing an error whenever I try to compile fortran code:
% gfortran Testing_Fortran.f90 -o Testing_Fortran
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/lib/libSystem.tbd' for architecture x86_64 collect2: error: ld returned 1 exit status
Looking at similar issues through the internet, the most common solutions I've found are to downgrade the XCode command line tools, and to reinstall gcc, but none of this worked.
I tried CLTools 14.1 and 13.4, and I am installing gcc via homebrew. The gfortran version is 12.2.0. I'm on MacOS Monterey 12.6.
Any ideas? Thanks in advance.
It's likely that your ld isn't the latest system linker: both on this help ticket and with a coworker the problem was that ld pointed to one from Anaconda. If your $PATH is set up so that Anaconda's ld has higher preference over the system linker, this will explain it:
$ which -a ld
/blah/anaconda3/bin/ld
/usr/bin/ld
If that's the case, reorder your PATH to put anaconda's directory after /usr/bin. Then, which ld should point to the system ld, and you should be good to go.

dyld: Symbol not found: __ZdaPvm - Running KING on Mac OS X

I'm having an issue running KING on Mac OS X . It has to do with a dyld link error, I think. Does anybody have any suggestions on how to fix this error?
Thanks in advance.
> ./king -b ./ex/ex.bed
Returns:
dyld: Symbol not found: __ZdaPvm
Referenced from: /Users/gaelgarcia/Downloads/./king (which was built for Mac OS X 10.13)
Expected in: /usr/local/lib/libstdc++.6.dylib
in /Users/gaelgarcia/./king
Abort trap: 6
I had similar issues trying to use the provided precompiled Mac version. I was able to get a running version built from source running the following in the unzipped source directory:
clang++ -L /opt/local/lib/libomp/ -lm -lz -O2 -fopenmp -o king *.cpp
having first installed libomp in the above directory. I use Macports, so I did this with
port install libomp
For Homebrew users, the recommendation seems to be to simply install llvm, which now includes openmp support directly.
EDIT: Having installed llvm via Homebrew (brew install llvm), the command that got KING properly built and running on my Mac OS 10.12 was:
/usr/local/Cellar/llvm/6.0.0/bin/clang++ -I /usr/local/Cellar/llvm/6.0.0/include -L /usr/local/Cellar/llvm/6.0.0/lib -O2 -fopenmp -lm -lz -o king *.cpp
Running the newly built executable with the example .bed file provided:
> ./king -b ../ex/ex.bed
KING 2.1.3 - (c) 2010-2018 Wei-Min Chen
The following parameters are in effect:
Binary File : ../ex/ex.bed (-bname)
For anyone like me looking for an answer years later, I managed to solve this problem by installing gcc with Homebrew.
brew install gcc
which includes libgfortran. Probably unnecessary, since I had dyld installed in Anaconda, but I found it was the easiest way to get King working on my mac.
Edit: I also had to set my DYLD_LIBRARY_PATH in my bash profile, as well, by going
nano ~/.bash_profile
and adding
export DYLD_LIBRARY_PATH=/opt/local/lib/libgcc/
or wherever the dynamic library libgcc_s.1.dylib is when you search for it on your computer.

Error when using gfortran on MacOS

I mostly work on linux and have no problems but want to occasionally use a Mac for work. Somehow gfortran does not work there, though. I installed it as instructed but when I try to compile something, this happens:
gfortran -o m_g_matrix2.x m_g_matrix.f90
ld: entry point (start) undefined. Usually in crt1.o for architecture x86_64
collect2: error: ld returned 1 exit status
I have no idea what this means and google search did not help. Did someone manage to get gfortran to work on Mac?
Thanks for the help!
I installed gcc binaries for yosemite from http://hpc.sourceforge.net
and also installed Xcode command-line tools as directed there.
gcc contains the gfortran compiler.
Seems to work well on macbook air with Yosemite.
JTN

How to compile RarCrack on Mac OSX?

I'm trying to compile Rarcrack by my command line, using command:
gcc -pthread rarcrack.c `xml2-config --libs --cflags` -O2 -o rarcrack
I am using the latest version of Xcode with command line tools.
Undefined symbols for architecture x86_64:
"_savestatus", referenced from:
_loadstatus in rarcrack-sh2Aob.o
_status_thread in rarcrack-sh2Aob.o
_crack_thread in rarcrack-sh2Aob.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I keep getting these architecture errors. Any dice on the meaning?
Today I wanted a small .rar/.zip password cracker and came across Rarcrack.
I was able to compile Rarcrack(from http://rarcrack.sourceforge.net/) to Mac OSX(my Github: https://github.com/jaredsburrows/Rarcrack).
Basically, Mac OSX's version of GCC did not like the usage of the many inline functions that were in the original code. I removed the inline functions, making them normal functions and with a few other minor changes got it to compile. I checked that it worked by running rarcrack on the examples provided.
How to compile:
$ git clone https://github.com/jaredsburrows/Rarcrack
$ cd Rarcrack
$ make

Resources