Hi,

Just to signal that this library "libglut32.a" 32 bit  don't "do the job" and seems bugged or incomplete (but  library "libglut32.a" 64 bit for toolchain "x86_64-w64-mingw32" is complete).

I join my test propgram, in which all instructions to reproduce this "bug" is explained in detail into comments.

Thank's.

Regards.

Thierry D
/* -------------        Beginning of file : "very_simple_glut.c"        
-----------             */

/*      
        An simply program just to test if GLUT is correctly configured on yous 
system/development environment.
        
        Generations of program success into Cygwin 64b terminal (with some 
changes), and tests also either in
        same Cygwin terminal or into command console Win32 (.ie. launch of 
"CMD" to open Windows terminal).
        
        First, open ou your system an Cygwin terminal and CMD win32 terminal 
(two different process on Win32).
        After, you can either use two source file (but same content mandatory), 
one in Cygwin environment (for
        me source file stored in "/home/'user'/Sources/OpenGL" directory with 
'user' is your ident to use Cygwin,
        by default when I open Cygwin terminal, I'm positioned on $HOME .ie. 
/home/'user'), and one stored in
        "normal" directory of Win32 system (for me, C:\src\OpenGL), or, you can 
use only one source file, for me
        "C:\src\OpenGL\very_simple_glut.c" and access this to generation into 
Cygwin terminal by this designation
        "/cygdrive/C/src/OpenGL/very_simple_glut.c". In last case, it's same an 
unique source file ...
        But, GCC don't work in same manner, aither you generate application 
with result of generation stored in
        directory managed into Cygwin (.ie. /.../... with no 
/cygdrive/'letter_device'/) or you generate  
        application with result of generation stored in directory managed by 
win32 system (.ie. 
        /cygdrive/C/.../...). In first case, if you design result of GCC 
generation with no extension (like on
        Unix/Linux like systems) by "-o 'target_name'", then no extension is 
added, but if you exactly use same 
        syntax with GCC but if you are directly postioned into 
/cygdrive/C/.../..., then GCC add autmatically 
        the extension ".exe" at designation name of target. But, this is 
transparent if you lauch program into
        Cygwin terminal, you can lauch with simple "./very_simple_glut" 
(extension ".exe" is it the default ?)
        
                a) with GCC "native" 64b installed into Cygwin 64b :
                        "gcc.exe -Wall -m64 very_simple_glut.c  -o  
very_simple_glut  -lglut -lGLU -lGL"
                An error appear, if you try to run "./very_simple_glut" because 
by default with "native" GCC, 
                use of library "glut", "GLU" and "GL" is based on GLX layer 
.ie. OpenGL on X environment.
                Message of error is described after :
                        "Beginning of program GLUT.
                        freeglut (./very_simple_glut): failed to open display 
''"
                This last line is very important because it see that is not 
really library "native" GLUT is used by 
                default, but "freeglut" (free and open-source replacement of 
GLUT library protected by Copyright ...).
                But, the source of error is because no DISPLAY variable are 
available to execute X application.
                Then,you must start en X server into CYGWIN and also define 
DISPLAY variable too by :
                        "startxwin -- -listen tcp &"            // Launch X 
Server on CYGWIN/X with enable network connexions
                        "export DISPLAY=localhost:0.0"          // Mandatory to 
see result on "localhost" .ie. your installation
                NB : An new process XWin turn on your Win32 system.
                NB2 : You can launch this X server autoamtically during your 
opening Cygwin terminal, with add last 
                instructions into your ".bashrc" file or your ".profile" file 
(present into your connexion directory 
                /home/'user'). 
                Try to rerun "./very_simple_glut" and window appear on screen 
with "X" at top left (reveal X application)
                and next messages on console :
                        "./very_simple_glut"
                        Beginning of program GLUT.
                        Window's creation.
                        Nothing draw at window.
                        Wait user event.
                until you close window by clicking on "x" symbol at top rigth 
of window (user action -> close).
                NB : last message insered into source file ("printf("End of 
program GLUT.\n");" don't appear ...
                To finish this test, you can also run this program into command 
console Win32 (CMD) by :
                        "very_simple_glut.exe"   ... and error appear in 
message box : ""cygwin1.dll" is inaccessible"
                Normal, you must add directory C:\cygwin64\bin at your PATH to 
permit access at this dll :
                        "set PATH=C:\cygwin64\bin;%PATH%" 
                Retest progamby same syntax "very_simple_glut.exe", but at new 
error appear : 
                        "Beginning of program GLUT.
                        freeglut (very_simple_glut): failed to open display ''"
                Normal too, an X application don't run if you have not define 
an variable DISPLAY (you can use X server
                launch into Cygwin terminal directly on your Win32 system, 
either, you can start another X server like
                VcXsrv). Then, after type next command into CMD console "set 
DISPLAY=localhost:0.0", you can run program
                        "very_simple_glut.exe"                                  
                and next lines appear
                        Beginning of program GLUT.
                        Window's creation.
                        Nothing draw at window.
                        Wait user event.
                until you click on button "close" of recent opened window (X 
interface like into Cygwin terminal).
                NB : last message insered into source file ("printf("End of 
program GLUT.\n");" don't appear ...
        
                b) with GCC included in MinGW64 installed into CYGWIN 64b (here 
program is not X application) :
                If you want that this generation will be success, you must add 
new directory at your PATH by command :
                        "export 
PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH"
                And, after, you can generate program with :
                        "x86_64-w64-mingw32-gcc.exe -Wall 
-I/usr/x86_64-w64-mingw32/sys-root/mingw/include  \
                        very_simple_glut.c -o very_simple_glut.exe 
-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib \
                        -lglut32 -lglu32 -lopengl32 -lgdi32 -lwinmm -luser32 
-lkernel32 -mwindows"
                Test success with run program by :
                        "./very_simple_glut.exe"
                        Beginning of program GLUT.
                        Window's creation.
                        Nothing draw at window.
                        Wait user event.
                NB : last message insered into source file ("printf("End of 
program GLUT.\n");" don't appear ...
                To finish this test, you can also run this program into command 
console Win32 (CMD) by :
                        "very_simple_glut.exe"                          but no 
one message appear on this console ??? 

                c) with GCC included in MinGW32 installed into CYGWIN 64b (here 
program is not X application) :
                If you want that this generation will be success, you must add 
new directory at your PATH by command :
                        "export 
PATH=/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH"    (Prefer after reopen 
CYGWIN terminal)
                And, after, you can generate program with :
                        "i686-w64-mingw32-gcc.exe -Wall 
-I/usr/i686-w64-mingw32/sys-root/mingw/include  \
                        very_simple_glut.c -o very_simple_glut.exe 
-L/usr/i686-w64-mingw32/sys-root/mingw/lib \
                        -lglut32 -lglu32 -lopengl32 -lgdi32 -lwinmm -luser32 
-lkernel32 -mwindows"
                But, generation failed with messages :
                        
"/usr/lib/gcc/i686-w64-mingw32/13/../../../../i686-w64-mingw32/bin/ld: 
/tmp/ccRBwBc8.o:very_simple_gl:(.text+0x1c): undefined reference to 
`_imp____glutInitWithExit@12'
                        
/usr/lib/gcc/i686-w64-mingw32/13/../../../../i686-w64-mingw32/bin/ld: 
/t/usr/x86_64-w64-mingw32/sys-root/mingw/libmp/ccRBwBc8.o:very_simple_gl:(.text+0x3f):
 undefined reference to `_imp____glutCreateWindowWithExit@8'
                        
/usr/lib/gcc/i686-w64-mingw32/13/../../../../i686-w64-mingw32/bin/ld: 
/tmp/ccRBwBc8.o:very_simple_gl:(.text+0x61): undefined reference to 
`_imp____glutCreateMenuWithExit@8'
                        collect2: error: ld returned 1 exit status
                I search to explain why these symbols are unreferenced with 
tool "nm" by :
                        "nm -A 
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a | grep glutInit"
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00041.o:00000000 
I __imp__glutInitWindowSize@8
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00041.o:00000000 
T _glutInitWindowSize@8
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00040.o:00000000 
I __imp__glutInitWindowPosition@8
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00040.o:00000000 
T _glutInitWindowPosition@8
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00039.o:00000000 
I __imp__glutInitDisplayString@4
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00039.o:00000000 
T _glutInitDisplayString@4
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00038.o:00000000 
I __imp__glutInitDisplayMode@4
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00038.o:00000000 
T _glutInitDisplayMode@4
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00037.o:00000000 
I __imp__glutInit@8
                        
/usr/i686-w64-mingw32/sys-root/mingw/lib/libglut32.a:libglut32s00037.o:00000000 
T _glutInit@8
                And, if I compare with ""nm -A 
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libglut32.a | grep glutInit" then 
                I constat that many entry points, like "*glutInitWithExit*", 
are not present into libglut32.a library into toolchain 
                "i686-w64-mingw32". I decide to search an implementation of 
GLUT generated with MinGW32 on Internet.
                I find this on site 
https://www.transmissionzero.co.uk/computing/using-glut-with-mingw/ and I 
decide to extract 
                library 32 bit "libglut32.a" from zip file donwnloaded into 
/usr/x86_64-w64-mingw32/sys-root/mingw/lib directory.
                After verification that entry point "*glutInitWithExit*" is at 
new preent, I rerun generation of program GLUT. 
                Test success with run program by :
                        "./very_simple_glut.exe"
                        Beginning of program GLUT.
                        Window's creation.
                        Nothing draw at window.
                        Wait user event.
                NB : last message insered into source file ("printf("End of 
program GLUT.\n");" don't appear ...
                To finish this test, you can also run this program into command 
console Win32 (CMD) by :
                        "very_simple_glut.exe"                          but no 
one message appear on this console ??? 
                        
                Conclusion : Library "libglut32.a" 32b into toolchain 
"i686-w64-mingw32" is "bugged" into CYGWIN 64b/MinGW32, 
                        but not library "libglut32.a" 64b into toolchain 
"x86_64-w64-mingw32". 
                        First library generated with "#define 
GLUT_DISABLE_ATEXIT_HACK" option ???
                        
NB : Many useful informations during startup of X Server into Cygwin terminal :

$
Welcome to the XWin X Server
Vendor: The Cygwin/X Project
Release: 1.21.1.21
OS: CYGWIN_NT-10.0-26200 MSI 3.6.6-1.x86_64 2026-01-09 17:39 UTC x86_64
OS: Windows 10  [Windows NT 10.0 build 26200] x64
Package: version 21.1.21-1 built 2026-01-16

XWin was started with the following command line:

/usr/bin/XWin :0 -multiwindow -listen tcp -auth
 /home/thierry/.serverauth.160

(II) xorg.conf is not supported
(II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
winUpdateDpi - primary monitor native DPI x 96 y 96
LoadPreferences: /home/thierry/.XWinrc not found
LoadPreferences: Loading /etc/X11/system.XWinrc
LoadPreferences: Done parsing the configuration file...
winDetectSupportedEngines - RemoteSession: no
winDetectSupportedEngines - DirectDraw4 installed, allowing ShadowDDNL
winDetectSupportedEngines - Returning, supported engines 00000005
winSetEngine - Multi Window or Rootless => ShadowGDI
winScreenInit - Using Windows display depth of 32 bits per pixel
winAllocateFBShadowGDI - Creating DIB with width: 1920 height: 1080 depth: 32
winFinishScreenInitFB - Masks: 00ff0000 0000ff00 000000ff
winInitVisualsShadowGDI - Masks 00ff0000 0000ff00 000000ff BPRGB 8 d 24 bpp 32
MIT-SHM extension disabled due to lack of kernel support
XFree86-Bigfont extension local-client optimization disabled due to lack of 
shared memory support in the kernel
glWinSelectGLimplementation: Loaded 'cygnativeGLthunk.dll'
(II) AIGLX: Testing pixelFormatIndex 1
GL_VERSION:     4.6.0 - Build 27.20.100.8190
GL_VENDOR:      Intel
GL_RENDERER:    Intel(R) UHD Graphics
(II) GLX: enabled GLX_SGI_make_current_read
(II) GLX: enabled GLX_SGI_swap_control
(II) GLX: enabled GLX_MESA_swap_control
(II) GLX: enabled GLX_SGIX_pbuffer
(II) GLX: enabled GLX_ARB_multisample
(II) GLX: enabled GLX_SGIS_multisample
(II) GLX: enabled GLX_ARB_fbconfig_float
(II) GLX: enabled GLX_EXT_fbconfig_packed_float
(II) GLX: enabled GLX_ARB_create_context
(II) GLX: enabled GLX_ARB_create_context_profile
(II) GLX: enabled GLX_ARB_create_context_robustness
(II) GLX: enabled GLX_EXT_create_context_es2_profile
(II) GLX: enabled GLX_ARB_framebuffer_sRGB
(II) AIGLX: enabled GLX_MESA_copy_sub_buffer
(II) 108 pixel formats reported by wglGetPixelFormatAttribivARB
(II) 72 fbConfigs
(II) ignored pixel formats: 0 not OpenGL, 0 unknown pixel type, 36 unaccelerated
(II) GLX: Initialized Win32 native WGL GL provider for screen 0
winPointerWarpCursor - Discarding first warp: 960 540
(--) 8 mouse buttons found
(--) Setting autorepeat to delay=500, rate=31
(--) Windows keyboard layout: "0000040C" (0000040c) "French (Legacy, AZERTY)", 
type 7
(--) Found matching XKB configuration "French (Standard)"
(--) Model = "pc105" Layout = "fr" Variant = "none" Options = "none"
Rules = "base" Model = "pc105" Layout = "fr" Variant = "none" Options = "none"
winInitMultiWindowWM - DISPLAY=:0.0
winMultiWindowXMsgProc - DISPLAY=:0.0
winInitMultiWindowWM - xcb_connect () returned and successfully opened the 
display.
winProcEstablishConnection - winInitClipboard returned.
winClipboardThreadProc - DISPLAY=:0.0
winMultiWindowXMsgProc - xcb_connect() returned and successfully opened the 
display.
winClipboardProc - xcb_connect () returned and successfully opened the display.
Using Composite redirection

        To proceed with another environment, now we test generation of this 
simple program GLUT
        with Ubuntu 24.04 (Linux) installed into WSL2 virtualization on Win32 
system.
        
        Before, you must install correctly WSL2 on your Win32 system,an after 
choose installation
        of Ubuntu 24.04 into WSL2, and after open an Ubuntu terminal to upgrade 
and update your
        configuration in "root" mode, and finally install all needed package : 
development package,
        make, cmake, zip, unzip, and also package mingw64 by "sudo apt-get 
install gcc-mingw-w64".
        With last package, you can build "Win32" native application into in 
Ubuntu terminal (like 
        into CMD console command, with package MinGW64 installed on your win32 
system), either in 
        32 bit or 64 bit.
        Like with CYGWIN 64, you can either use two source file (but same 
content mandatory), one 
        in WSL2 UBUNTU 24.04 environment (for me source file stored in 
"/home/'user'/src/OpenGL" 
        directory with 'user' is your ident to use Ubuntu, by default when I 
open Linux terminal, 
        I'm positioned on $HOME .ie. /home/'user'), and one stored in "normal" 
directory of Win32 
        system (for me, C:\src\OpenGL), or, you can use only one source file, 
for me
        "C:\src\OpenGL\very_simple_glut.c" and access this to generation into 
Linux terminal by 
        this designation "/mnt/c/src/OpenGL/very_simple_glut.c". In last case, 
it's same an unique 
        source file ...
        
        a) with "native" GCC 64 bit (generation of X application because is 
standard OpenGL graphic
        layer by default on Unix/Linux like system) :
                "gcc -Wall very_simple_glut.c -o very_simple_glut  -lglut -lGLU 
-lGL" 
        After that, you can directly launch your "new" application X (server X 
is already activated)
        by  "./very_simple_glut" and new open window appear and next messages 
too :
                Beginning of program GLUT.
                Window's creation.
                Nothing draw at window.
                Wait user event.
        you close window by clicking on "x" symbol at top rigth of window (user 
action -> close).
        NB : last message insered into source file ("printf("End of program 
GLUT.\n");" don't appear ...
        NB2 : no need to "manually" launch X server in this configuration, X 
server is automatically 
                available.
        
        b) with GCC 64b included into package MinGW64 (recall : "sudo apt-get 
install gcc-mingw-w64") :
        You can generate this program with next command 
                "x86_64-w64-mingw32-gcc-win32 -Wall 
-I/usr/x86_64-w64-mingw32/include very_simple_glut.c \
                        -o very_simple_glut.exe -L/usr/x86_64-w64-mingw32/lib  
-lglut32 -lglu32 -lopengl32      \
                        -lgdi32 -lkernel32"

                "i686-w64-mingw32-gcc-win32 -Wall -m32 
-I/usr/i686-w64-mingw32/include very_simple_glut.c \
                        -o very_simple_glut.exe -L/usr/i686-w64-mingw32/lib  
-lglut32 -lglu32 -lopengl32        \
                        -lgdi32 -lkernel32"
*/

#if _WIN32
#include <windows.h>
#endif
#if __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include <stdio.h>
// #define _STDCALL_SUPPORTED
// #define APIENTRY __stdcall
// #define GLUT_DISABLE_ATEXIT_HACK

void display()
{
}

int main(int argc, char **argv)
{
  printf("Beginning of program GLUT.\n");
  glutInit(&argc, argv);
  
/* Error detected with initial source provided :  ERROR:  glutMainLoop called 
with no windows created.
        Adding two next lines to resolve this error, espacially the last :      
glutCreateWindow                        */
        
  printf("Window's creation.\n");
  glutCreateWindow("GLUT program");
  printf("Nothing draw at window.\n");
  glutDisplayFunc(display);
  printf("Wait user event.\n");
  glutMainLoop();
  printf("End of program GLUT.\n");
}

/* -------------                End of file : "very_simple_glut.c"       
-----------            */
-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to