This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Cygwin, gfortran and C interop
- From: Anthony Stone <ajs1 at cam dot ac dot uk>
- To: fortran at gcc dot gnu dot org
- Date: Mon, 01 Jun 2009 09:12:51 +0100
- Subject: Cygwin, gfortran and C interop
I am trying to link a program that uses the C interoperability features
of Fortran 2003 to call OpenGL routines. This works fine under Linux,
but not under Cygwin. The problem is that the linker is looking for
(e.g.) '_glBegin':
gl_module.o:gl_module.F90:(.text+0x293c): undefined reference to `_glBegin'
but the OpenGL library in /lib/w32api/libopengl32.a provides '_glBegin@4':
$ nm 'c:\cygwin\lib\w32api\libopengl32.a' | grep glBegin
00000000 I __imp__glBegin@4
00000000 T _glBegin@4
The Fortran code contains the following interface:
INTERFACE
SUBROUTINE glBegin(mode) BIND(C,NAME="glBegin")
IMPORT
INTEGER(GLenum), VALUE :: mode
END SUBROUTINE glBegin
END INTERFACE
Can I modify the interface to persuade gfortran to generate the right
reference? The Nag compiler provides the possibility of modifying the
interface to
INTERFACE
SUBROUTINE glBegin(mode) BIND(C,NAME="__stdcall glBegin")
IMPORT
INTEGER(GLenum), VALUE :: mode
END SUBROUTINE glBegin
END INTERFACE
and then it generates a reference to _glBegin@4 as required.
gfortran doesn't accept this, but does it provide some other way round
the problem?
Anthony Stone