implemented SUPER key/modifier support on windows
[freeglut] / README.cygwin_mingw
1 Glut then!
2
3 By Jean-Seb on Friday July 10, 2009, 00:18
4 Translated by Babelfish with a scrub from John F. Fay.  For points of confusion
5 please refer to the original French version.
6
7 Freeglut is an open-source evolution of GLUT.
8 Under Windows, one can use it with Cygwin.
9 Easy? Yes, if one agrees to distribute "cygwin1.dll".
10 Let us help freeglut gain its independence !
11 Update 10/7/2009: generation of a library for linking without the DLL.
12
13
14 Grabbing the sources
15
16     * Download the sources for version 2.6.0 which integrates recent changes.
17     * Using version 2.6 is better than the 2.4-stable branch because many
18       bugs have been corrected.
19     * You will find the sources on the site of Freeglut:
20           o http://freeglut.sourceforge.net/
21
22
23 Goals
24
25     * We will create a DLL for Cygwin, and an independent static library
26     * We will also create a dynamic library, allowing linking with the DLL.
27
28
29 List of generated files
30
31     * freeglut.dll: a traditional DLL for the dynamic linkage.
32     * libfreeglut.a: the static library. The final program is autonomous (at
33       least for OpenGL).
34     * libfreeglutdll.a: the dynamic library. The final program needs
35       freeglut.dll.
36
37
38 Preparation
39
40     * Extract the files from the freeglut archive.
41     * Go in the directory src (located at the root of the Freeglut directory),
42       and create a "Gl" sub-directory
43           o In this sub-directory, copy the files of the directory "include/Gl"
44
45     * Why is it necessary to create a "Gl" directory for compilation?
46           o I needed it to simplify things during my tests.
47           o If not you can create the repertories directly, and copy the files
48             as indicated in the point installation (see below).
49
50     * Do a little housekeeping in /lib:
51           o Erase all the references to the glut, so as not to conflict with the
52             linking.
53           o This stage is optional, you can also choose to do the housekeeping
54             only after a successful compilation of Freeglut.
55           o In your enthusiasm to clean things up, be careful not to erase the
56             library glu32.lib (not to be confused with glut32.lib).
57
58
59 Compilation
60
61     * Forget the "./configure, make, make install" triptych.
62           o It does not go at all with Cygwin.
63
64     * Here Makefile which will make the deal:
65
66 #Makefile for Freeglut 2.6.0-rc and Cygwin
67 #To place in the directory 'src/Common'
68
69 sources=$ (wildcard *.c)
70 objs=$ (sources: .c=.o)
71 libname=freeglut
72
73
74 CFLAGS=-O2 - DTARGET_HOST_MS_WINDOWS - DX_DISPLAY_MISSING - DFREEGLUT_STATIC - I./
75 LDFLAGS=-lopengl32 - lgdi32 - lwinmm
76
77 nocyg=-mno-cygwin - mwindows
78
79 all: $ (objs)
80         #construction DLL related to cygwin1.dll
81         gcc $(nocyg) $(objs) -shared $(LDFLAGS) -o $(libname).dll
82         nm $(libname).dll  | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
83         dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
84
85         #construction static library independent of cygwin
86         ar cr lib$(libname).a $(objs)
87         #pas inevitably obligatory (creation of an index to accelerate the accesses)
88         ranlib lib$(libname).a
89
90 %.o: %.c
91         gcc $(nocyg) -c $(CFLAGS) $<
92
93 clean:
94         rm -f *.o $(libname).dll $(libname).def lib$(libname)dll.a lib$(libname).a
95
96
97
98
99 Some remarks on the Makefile
100
101     * This makefile creates a DLL, a static library (a file, in other words) and
102       the dynamic library which will allow the use of the DLL.
103
104     * Do not try to strip the static library! You may not be able to compile
105       applications with static library any more.
106           o On the other hand, you can strip the final executable obtained after
107             compiling your application.
108
109     * I chose to call the DLL and the libraries by their "true names":
110       freeglut.dll libfreeglutdll.a and libfreeglut.a.
111           o Script configures recreated (for reasons of compatibility with the
112             old GLUT library) glut.dll and libglut.a.
113           o During the my tests, I had conflicts with an authentic "glut" which
114             trailed in my "/lib". I decided to call the things by their name, in
115             order to avoid confusions.
116           o Nothing prevents you from renaming the DLL, if you need to use GLUT
117             programs which you cannot recompile.
118
119     * The dynamic library is generated starting from the DLL.
120           o For reasons of brevity, I used awk. It generates the export file
121             used by dlltool.
122           o The only notable thing is the selection of the functions whose name
123             starts with _glut, in order to avoid including in the dynamic
124             library the functions that are not related to freeglut.
125           o then, one uses dlltool in a very traditional way.
126
127 nm $(libname).dll  | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
128 dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
129
130
131
132
133 Installation
134
135     * Copy libfreeglut.a, libfreeglutdll.a into the Cygwin directory /lib.
136     * Copy freglut.dll in the system32 of Windows (this is practical, but not
137       clean!).
138     * Copy the files headers of Freeglut (/include/gl) into the Cygwin directory
139       /usr/include/Gl.
140     * Copy the files headers (always /include/gl) into /usr/include/mingw/Gl:
141       this is used for compilations with the flag - mno-cygwin, which uses the
142       includes in mingw.
143           o You may need to erase the old GLUT include files if you installed it
144             with Cygwin.
145
146
147 Use of the library
148
149     * We will test with the program shapes, found in progs/demonstrations/shapes
150           o -mno-cygwin is used to force the use of Mingw without the large
151             dependence cygwin1.dll.
152           o -mwindows is only used to remove the horrible Shell window (very
153             useful for the settling, on the other hand).
154           o -L. (note the period after the "L"): I left libfreeglut.a,
155             libfreeglutdll.a and freeglut.dll in the test directory, at the time 
156             of the tests.
157
158
159 Compilation of the static freeglut library, without cygwin
160
161     * All the simplicity lies in the define: -DFREEGLUT_STATIC
162           o It serves to obtain good decoration of the function names in the
163             imports of the lib Freeglut.
164           o You can test without and use a hex editor to see the differences
165             in the objects.
166     * attention with the order of the libraries: -lfreeglut (static) must be
167       before the declaration of the dynamic libraries.
168
169     * gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin -mwindows -DFREEGLUT_STATIC
170
171
172 Compilation with DLL freeglut, without cygwin
173
174     * For the define, see the notices above
175     * The order of the libraries is no longer important.
176
177     * gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin -DFREEGLUT_STATIC
178
179
180 Compilation with DLL freeglut, Cygwin
181
182     * This example is given only for reference, the topic of this ticket being
183       to get rid of Cygwin.
184           o Let us say that can be used to make the point (and later).
185
186     * gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
187
188
189
190 Where are the dooooocs?
191
192     * Freeglut is delivered with its documentation, more very up to date.
193           o It seems that there is a problem with the original GLUT
194             documentation. Not only it does not correspond completely to the
195             operation of Freeglut, but moreover, its author (Mark Kilgard)
196             copyrighted it. Its distribution is thus difficult.
197
198     * Jocelyn Fréchot undertook a levelling of the docs for version 2.6.0. One can find them on his site for the moment:
199           o http://jocelyn.frechot.free.fr/freeglut/
200
201
202 Something survived...
203
204     * I also tested the recompiling of the demonstrations of the original lib
205       GLUT (peace with its ashes).
206           o Nothing in particular to be announced.
207
208     * Thank you with all the courageous maintainers for Freeglut, that one
209       believed dead, but which still move.