main.o(.text+0x29e): undefined reference to `getarg_
Daniel Heiserer
Daniel.Heiserer@bmw.de
Wed Feb 16 09:37:00 GMT 2005
sgk@troutmask.apl.washington.edu wrote:
> On Tue, Feb 15, 2005 at 09:03:15AM +0100, Daniel Heiserer wrote:
>
>>>>I downloded a ia32-linux binary from the gfortran page.
>>>>I found out why my example did not work:
>>>>c----------------
>>>> PROGRAM test
>>>> implicit none
>>>> external getarg
>>>> character*80 argv(50)
>>>> integer*4 argc
>>>> do argc=1,iargc()
>>>> call getarg(argc,argv(argc))
>>>> write(6,'(" Argument ",I2," is ",A)') argc, argv(argc)
>>>> enddo
>>>> END
>>>>c----------------
>>>>
>>>>The key point is the "external getarg" command. If I remove it it works.
>>>>I do not know if this defintion is an error on my side or if it is a bug
>>>>of the compiler, but other f90/f77 compilers required it, and g77 as
>>>>well as g95 got along with it.
>>>>
>>>
>>>
>>>"external getarg" tells the compiler that you are linking a
>>>user-defined external procedure. "getarg" in gfortran is an
>>>intrinsic procedure if you use the -std=gnu option, which is
>>>the default. If you use -std=f95, then "getarg" is not an
>>>intrinsic procedure, and gfortran would issue an error during
>>>the link stage because getarg_() would be missing if you do
>>>not supply one.
>>
>>I appreciate the fact that it is part of the delivery, but
>>as is there is no compatibility with other fortran compiler and g77.
>>
>
>
> What do the other fortran compilers do if you change
> "external getarg" to "intrinsic getarg"? If they compile
> the both codes, then IMHO something is wrong. A procedure
> cannot be both an external and an internal procedure
> (again IMHO).
Here the results with "intrinsic":
---------------------
ia32linux/gfortran:
./getarg
Argument 1 is
---------------------
hp-ux-itanium2 f90:
./getarg
--------------------
Here the results with "external":
ERROR in both compilers.
However the iargc() counter is treated different (+1 with gfortran) in
both compilers. What is "right"?
with gfortran I get > ./getarg 1 2 3 4
Argument 1 is 1
Argument 2 is 2
Argument 3 is 3
Argument 4 is 4
Argument 5 is
> I'm also beginning to believe that backwards compatibility
> with g77 may be a mistake because of some of the choices
> that author of g77 made.
I do not care about g77 combatibility as long as the gfortran works
along the standard.
best regards, daniel
More information about the Fortran
mailing list