Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, I recently installed Scientific Linux 5.5. I am a newbie. I tried to compile a very simple fortran code test1.f by only writing make test1 on the command window. ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    6

    Exclamation Linux fortran error

    Hello,
    I recently installed Scientific Linux 5.5. I am a newbie. I tried to compile a very simple fortran code test1.f by only writing make test1 on the command window. Then, the following error came:

    gcc test1.f -o test1
    usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function '_start':
    (.text+0x20): undefined reference to 'main'
    tmp/cccpdmKU.o: In function 'MAIN__':
    test1.f:(.text+0x1b): undefined reference to `_gfortran_set_std'
    test1.f:(.text+0x50): undefined reference to `_gfortran_st_write'
    test1.f:(.text+0x66): undefined reference to `_gfortran_transfer_character'
    test1.f:(.text+0x72): undefined reference to `_gfortran_st_write_done'
    test1.f:(.text+0x7c): undefined reference to `_gfortran_stop_numeric'
    collect2: ld returned 1 exit status
    make: *** test1 Error 1

    Does anyone have any solution for that? I searched the net, somebody advised to change make.conf file by editing the LOADER=GCC with LOADER=GFORTRAN. But I couldnot find a similar file in my system.
    Thanks in advance.

  2. #2
    Just Joined!
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    52
    Hi, this is a linker-error, perhaps the library-path is wrong?

    Anyhow, could you try with gfortran instead? (might resolve some of the path-issues etc)

    Code:
    gfortran -std=legacy test1.f -o test1
    Then, if that does not work, rename to f90 (force Fortran90 mode) and try again.

    Finally, if things still doesn't work - could you post your code here?

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    6
    Thank you. It worked.
    But do you know how I can correct this permanently? I will look for gfortran program files. Since I am new in Linux I couldnt figure where the program files are.
    Thanks again

  4. #4
    Just Joined!
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    52
    I guess a permanent solution is to use gfortran

    As to "gfortran program files" I assume you mean the libraries? I don' t know where they are stored (I'm not *that* into Fortran), but I guess /var/lib and /usr/include are a good place to start.

    note: the -std=legacy will forcre gfortran to compile the files as Fortran-77 and in my (rather limited) experience, that makes a few strange bugs go away...

  5. #5
    Just Joined!
    Join Date
    May 2010
    Posts
    6
    I couldnt quite understand, but now it compiles correctly by only writing
    make test1
    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...