Problems compiling or linking Fortran programs


Up: In case of trouble Next: General Previous: In case of trouble



Up: In case of trouble Next: General Previous: In case of trouble


General


Up: Problems compiling or linking Fortran programs Next: Problems linking C programs Previous: Problems compiling or linking Fortran programs

    1. Q: When linking the test program, the following message is generated:
    f77 -g -o secondf secondf.o -L/usr/local/mpich/lib/sun4/ch_p4 -lmpi 
     invalid option -L/usr/local/mpich/lib/sun4/ch_p4 
     ld: -lmpi: No such file or directory 
    
    A: This f77 program does not accept the -L command to set the library search path. Some systems provide a shell script for f77 that is very limited in its abilities. To work around this, use the full library path instead of the -L option:
    f77 -g -o secondf secondf.o /usr/local/mpich/lib/sun4/ch_p4/libmpi.a 
    

    2. Q: When linking Fortran programs, I get undefined symbols such as
    f77  -c secondf.f 
     secondf.f: 
      MAIN main: 
     f77  -o secondf secondf.o -L/home/mpich/lib/solaris/ch_shmem -lmpi  
     Undefined                       first referenced 
      symbol                             in file 
     getdomainname                       
     /home/mpich/lib/solaris/ch_shmem/libmpi .a(shmempriv.o) 
     ld: fatal: Symbol referencing errors. No output written to secondf 
    
    There is no problem with C programs.

    A: This means that your C compiler is providing libraries for you that your Fortran compiler is not providing. Find the option for the C compiler and for the Fortran compilers that indicate which library files are being used (alternately, you may find an option such as -dryrun that shows what commands are being used by the compiler). Build a simple C and Fortran program and compare the libraries used (usually on the ld command line). Try the ones that are present for the C compiler and missing for the Fortran compiler.



Up: Problems compiling or linking Fortran programs Next: Problems linking C programs Previous: Problems compiling or linking Fortran programs