delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/09/18/20:41:40

From: colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters)
Subject: RE: SGI's opengl and cygnus
18 Sep 1997 20:41:40 -0700 :
Message-ID: <01BCC4F5.71A06560.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
To: "'Garner Chung'" <garnerbc AT uclink2 DOT berkeley DOT edu>
Cc: "'GNU-Win32'" <gnu-win32 AT cygnus DOT com>

Garner Chung[SMTP:garnerbc AT uclink2 DOT berkeley DOT 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 AT 4'
>simpleci.o(.text+0xc4b):simpleci.c: undefined reference to `wglMakeCurrent AT 8'
>simpleci.o(.text+0xc7e):simpleci.c: undefined reference to `wglMakeCurrent AT 8'
>simpleci.o(.text+0xc89):simpleci.c: undefined reference to
>`wglDeleteContext AT 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 AT 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 AT bird DOT fu DOT is DOT saga-u DOT ac DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019