Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fortran: Undefined symbols for architecture x86_64

I am using the gfortran compiler on mac osx mavericks. I have installed Xcode and command line tools. I am trying to compile a simple helloworld program with gfortran to test whether everything works, but unfortunately it doesn't work. The error message seems to suggest that I have no main function, but I don't see the error in the code:

      program hello
         print *, "Hello World!"
      end program hello

But when i try to compile using

gfortran helloworld.f

I get the following error:

Undefined symbols for architecture x86_64:
  "start", referenced from:
     -u command line option
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

I do not understand what is wrong and I am on the verge of despair. I tried with gfortran 4.8.2 as well as gfortran 4.9.0, I tried reinstalling Xcode and Command Line Tools but nothing seems to work.

I am aware similar questions have been asked, but I was not able to find a solution to my problem. I would be happy even with a sloppy workaround, as long as I can get the compiler to run...

like image 634
user3770102 Avatar asked Jun 24 '14 07:06

user3770102


1 Answers

Oh my dear. Found the solution about a minute after staring the bounty. Rather than using the recommended installer from https://gcc.gnu.org/wiki/GFortranBinaries I just installed it with

brew install gcc

The gfortran now compiled without complaining.

like image 130
qwerty_so Avatar answered Oct 31 '22 22:10

qwerty_so