This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]