This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

RE: SGI's opengl and cygnus


Garner Chung[SMTP:garnerbc@uclink2.berkeley.edu] wrote:
>I've been trying to compile some basic opengl programs using SGI's opengl
>implementation.  I started out by creating .a files from the opengl.dll and
>the glu.dll(not the opengl32.dll and the glu32.dll which are Microsoft's).
>
>impdef opengl.dll > opengl.def
>dlltool -k --def opengl.def --dllname opengl.dll --output-lib libopengl.a
>
>But then I ran into a problem:
>simpleci.o(.text+0xc33):simpleci.c: undefined reference to
>`wglCreateContext@4'
>simpleci.o(.text+0xc4b):simpleci.c: undefined reference to `wglMakeCurrent@8'
>simpleci.o(.text+0xc7e):simpleci.c: undefined reference to `wglMakeCurrent@8'
>simpleci.o(.text+0xc89):simpleci.c: undefined reference to
>`wglDeleteContext@4'
>
>But I soon realized that that was because of the "@NN"'s that are produced
>due to the fact that the wgl* functions are standard calls.

This is a correct evaluation of the problem.

>  So I removed
>the "STDCALL"'s from the wgl* function declarations which are in
><Windows32/Function.h>.

This is definitely the wrong solution. If you don't tell GCC that the
calls are STDCALL it will generate normal C calling convention calls
to those functions and they will fail...

[snip]
>(f:\Cygnus\home\opengl\misc\a.exe 1444) Error while dumping state (probably
>corrupted stack)

...because the stack will become totally out of whack (the technical term for
"corrupted").

Sorry if I sound harsh but: there's a *reason* all the prototypes are marked
STDCALL!

Fortunately for this particular case there is a reasonably easy solution.
The Cygnus source distribution includes .def files for opengl32 and glu32
among others. These .def files are for the MS versions of the OpenGL
libraries, but obviously, because the two sets of libraries are supposed
to be compatible, the function calls made available by the DLLs will be
the same (at least the vast majority of them). So:

 1. Get your hands on the opengl32.def and glu32.def files from the Cygnus
    source distribution (or any other source as long as the .def files
    include the precious @nn).

 2. Restore the header files to their original, STDCALL including state.

 3. Proceed from the dlltool step in your above process.

This should reduce to a handful, if not eliminate altogether, the
undefined references in your program.

Those references that remain undefined can be eliminated by simply
adding the name@nn that appears in the error message to the .def file
for the dll that exports the function of the appropriate name (which
you can use impdef to find).

This is somewhat painful (especially if you have to download and
unpack Cygnus' source distribution just for those two or three
files), but at least within the bounds of human endurance.

Colin.

-- Colin Peters - Saga Univ. Dept. of Information Science
-- colin@bird.fu.is.saga-u.ac.jp - finger for PGP public key
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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