How to fix the undefined reference errors

Asked By 20 points N/A Posted on -
qa-featured

Please help me fix the error ‘un defined reference to f – xargc’. Also the underscore problem is to be solved. How can I say the linker for ignoring the unresolved reference? The MKL with PGI compiler can be used and if can be used how can it be used?

SHARE
Answered By 0 points N/A #100507

How to fix the undefined reference errors

qa-featured

 

The following are the solutions for the problem above:
 
First, you can choose to add a C function that will be used to define and also assignsxarg & xargc and it will also add a call to the C function from the fortran main program. See example below:
 
        zarg.c:
        int    xargc;
        char **xargv;
        extern int    __argc_save;
        extern char **__argv_save;
        void zarg_() 
       {          
            /* call zarg() from fortran */
            xargc = __argc_save;
            xargv = __argv_save;
        }
The second workaround will be to recompile the file farg.f with 'pgf77 -c' and thereafter you will add the object to the link before -lmpich. In case the second underscore is needed especially for the global names, then you will need tor to include the second underscore option. Here is the source for farg.f:
 
   integer function mpir_iargc()
      mpir_iargc = iargc()
      return
      end
      subroutine mpir_getarg( i, s )
      integer       i
      character*(*) s
      call getarg(i,s)
      return
      end 
 
Lee Seen

Related Questions