1

I have a problem compiling some Fortran code with gfortran 4.8.1 on Windows 7. With some Fortran programs I get the error message:

c:/gcc/bin/../lib/gcc/i686-pc-mingw32/4.8.1/../../../../i686-pc-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3c): undefined reference to 'WinMain@16'

These are not programs that contain only function or subroutines!

Any help how to solve this problem?

Klaus Rohe
  • 782
  • 2
  • 7
  • 11
  • possible duplicate of [undefined reference to \`WinMain@16'](http://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16) – devnull Sep 09 '13 at 12:37
  • @Klaus Rohe: Please clarify what you mean by **these are not programs that contain only function or subroutines**. Are they programs (i.e. has a program statement) or code that just contains modules/functions/subroutines. Also does it happen when you are building programs or compiling dependent code. – cup Sep 16 '13 at 08:58

1 Answers1

0

I encountered this error when I changed the name of my program to "main", by which I mean

program main
    ! do stuff
end program main

When I changed it back to its original name (like xxx_main) the problem was resolved. When I encountered the problem, I was linking to an additional object module; I am unable to reproduce this with only a trivial "main" program.

I'm on gfortran 4.10.0 on Windows 10 and cygwin.

battey
  • 458
  • 4
  • 13