README.cygwin_mingw 7.9 KB

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