linux - Old Fortran Program: ld returned 1 exit status -


i have old fortran 77 program having trouble compiling / building normal with: gfortran -wall -o "filename" filename.f

it keeps giving me linker error:

$ gfortran -wall  ljewald.f   /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: in function `_start': (.text+0x18): undefined reference `main' collect2: error: ld returned 1 exit status 

eventually, tried: gfortran -wall -c -o "filename" filename.f gives me compiled binary file. ok great, man page gfortran sketching me out. here material -c option makes seem work:

   -c  not discard comments. comments passed through output file, except comments in processed directives, deleted        along directive.         should prepared side effects when using -c; causes preprocessor treat comments tokens in own right. example,        comments appearing @ start of directive line have effect of turning line ordinary source line, since        first token on line no longer '#'.         warning: handles c-style comments only. preprocessor not yet recognize fortran-style comments. 

so, after building this, using: gfortran -wall -c -o "ljewald" ljewald.f

i output file, isn’t executable...?

$ls -l ... -rw-rw-r--  1 j0h j0h    647 aug  9 16:36 ljewald  ... 

i cant execute file, if change mode chmod +x ljewald

what can avoid -c option, since using has quirks? , how can build executable of program? can explain, , tell me how fix this:?

/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: in function `_start': (.text+0x18): undefined reference `main' collect2: error: ld returned 1 exit status 

link source: http://nanocluster.umeche.maine.edu/ljewald.f

edit: problem not come lacking program (sorry, not awake :-)).

actually, line endings causing problem: when converted crlf on windows, gcc-4.8.1 successfuly compiles (after commenting out accepts).

however:

  • there many warnings (unused variables or formats)
  • accept should equivalent read, label 777 missing (for read format)
  • there lines tabulations, should avoided, when code indented spaces.

if have access windows box, may use notepad++ convert line endings , replace tabs.

if have many files repair, may try python script. can elaborate on following, use clean files according given rules (you can change cleanfile function according needs, here translates crlf, , removes useless blanks). it's in python 3, easy convert python 2 if needed.

# encoding: iso-8859-15  import sys, os, hashlib  def filehash(name):    f = open(name, "rb")    h = hashlib.sha512()    n = 4 * 1024 * 1024    while true:       r = f.read(n)       h.update(r)       if len(r) < n:          break    f.close()    return h.hexdigest()  def cleanfile(name):    v = os.stat(name)    = filehash(name)    atime = v[7]    mtime = v[8]    f = open(name, "rt", encoding="iso-8859-1")    u = f.readlines()    f.close()     n = len(u)    in range(n):       u[i] = u[i].rstrip()     while n > 0 , u[n - 1] == "":       n -= 1     if n == 0:       print("empty file {}".format(name))       os.remove(name)       return     #f = open(name, "wt", newline="\n")    f = open(name, "wt", encoding="iso-8859-1")    in range(n):       s = u[i]       f.write("{}\n".format(s))    f.close()     os.utime(name, (atime, mtime))    b = filehash(name)    if != b:       print("modif {}".format(name))  def manfile(name):    global exts    n = name.rfind(".")    if n < 0:       print("pass {}".format(name))    e = name[n + 1:].lower()     if e in ["f"]:       cleanfile(name)    else:       print("skip {}  -  {}".format(e, name))   ########### recursive directory traversal, don't whange after line ###########  def mandir(path):    try:       li = os.listdir(path)    except:       print("errd {}".format(path))       return    li.sort()    lilnk = [ ]    lifil = [ ]    lidir = [ ]    name in li:       c = os.path.join(path, name)       if os.path.islink(c):          lilnk.append(c)       elif os.path.isfile(c):          lifil.append(c)       elif os.path.isdir(c):          lidir.append(c)       else:          print("unkn {}".format(c))    c in lilnk:       os.remove(c)       pass    c in lifil:       manfile(c)    c in lidir:       mandir(c)    li = os.listdir(path)    if len(li) == 0:       try:          os.rmdir(path)       except oserror:          pass  mandir(sys.argv[1]) 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -