user4937378
user4937378

Reputation:

Undefined reference to `sleep` and `sizeof` instrinsics in gfortran

gfortran doesn't find intrinsic functions provided by GNU Fortran (sleep, sizeof, ...) :

undefined reference to `sleep_'

I've installed mingw32-base and mingw32-gcc-fortran from the MinGW Installation Manager.

This problem occurs even with this simple code:

program p
implicit none

    call SLEEP(1)

end program p

command : $ gfortran.exe -std=f2008 .\test.f08

In fact it works with $ gfortran.exe .\test.f08. However, it should work with the previous one.

Upvotes: 1

Views: 407

Answers (1)

The procedures you are using are NOT standard Fortran. When you explicitly ask for standard Fortran by -std=f2008, the compiler will not link the non-standard intrinsic procedures, because they are not in the standard you explicitly requested.

When you use

intrinsic sleep

you get a more explicit error message:

intrinsic sleep
               1
Error: The intrinsic ‘sleep’ declared INTRINSIC at (1) is not available
in the current standard settings but a GNU Fortran extension. Use an appropriate 
‘-std=*’ option or enable ‘-fall-intrinsics’ in order to use it.

So, as the message says, you can use -fall-intrinsics to enable the non-standard intrinsic procedures.

Upvotes: 3

Related Questions