File: compile.html

package info (click to toggle)
glfw3 3.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,460 kB
  • ctags: 10,390
  • sloc: ansic: 25,815; objc: 933; makefile: 11
file content (216 lines) | stat: -rw-r--r-- 19,031 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>GLFW: Compiling GLFW</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
	<div class="glfwheader">
		<a href="http://www.glfw.org/" id="glfwhome">GLFW</a>
		<ul class="glfwnavbar">
			<li><a href="http://www.glfw.org/documentation.html">Documentation</a></li>
			<li><a href="http://www.glfw.org/download.html">Download</a></li>
			<li><a href="http://www.glfw.org/media.html">Media</a></li>
			<li><a href="http://www.glfw.org/community.html">Community</a></li>
		</ul>
	</div>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Compiling GLFW </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#compile_deps">Dependencies</a><ul><li class="level2"><a href="#compile_deps_msvc">Dependencies using Visual C++ on Windows</a></li>
<li class="level2"><a href="#compile_deps_mingw">Dependencies with MinGW or MinGW-w64 on Windows</a></li>
<li class="level2"><a href="#compile_deps_mingw_cross">Dependencies using MinGW or MinGW-w64 cross-compilation</a></li>
<li class="level2"><a href="#compile_deps_xcode">Dependencies using Xcode on OS X</a></li>
<li class="level2"><a href="#compile_deps_x11">Dependencies using Linux and X11</a></li>
</ul>
</li>
<li class="level1"><a href="#compile_cmake">Generating files with CMake</a><ul><li class="level2"><a href="#compile_cmake_cli">Generating files with the CMake command-line tool</a></li>
<li class="level2"><a href="#compile_cmake_gui">Generating files with the CMake GUI</a></li>
</ul>
</li>
<li class="level1"><a href="#compile_options">CMake options</a><ul><li class="level2"><a href="#compile_options_shared">Shared CMake options</a></li>
<li class="level2"><a href="#compile_options_osx">OS X specific CMake options</a></li>
<li class="level2"><a href="#compile_options_win32">Windows specific CMake options</a></li>
<li class="level2"><a href="#compile_options_egl">EGL specific CMake options</a></li>
</ul>
</li>
<li class="level1"><a href="#compile_manual">Compiling GLFW manually</a></li>
</ul>
</div>
<div class="textblock"><p>This is about compiling the GLFW library itself. For information on how to build programs that use GLFW, see the <a class="el" href="build.html">Building programs that use GLFW</a> guide.</p>
<h1><a class="anchor" id="compile_deps"></a>
Dependencies</h1>
<p>To compile GLFW and the accompanying example programs, you will need <b>CMake</b>, which will generate the project files or makefiles for your particular development environment. If you are on a Unix-like system such as Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or Homebrew, you can simply install its CMake package. If not, you can get installers for Windows and OS X from the <a href="http://www.cmake.org/">CMake website</a>.</p>
<p>Additional dependencies are listed below.</p>
<p>If you wish to compile GLFW without CMake, see <a class="el" href="compile.html#compile_manual">Compiling GLFW manually</a>.</p>
<h2><a class="anchor" id="compile_deps_msvc"></a>
Dependencies using Visual C++ on Windows</h2>
<p>The Microsoft Platform SDK that is installed along with Visual C++ contains all the necessary headers, link libraries and tools except for CMake.</p>
<h2><a class="anchor" id="compile_deps_mingw"></a>
Dependencies with MinGW or MinGW-w64 on Windows</h2>
<p>Both the MinGW and the MinGW-w64 packages contain all the necessary headers, link libraries and tools except for CMake.</p>
<h2><a class="anchor" id="compile_deps_mingw_cross"></a>
Dependencies using MinGW or MinGW-w64 cross-compilation</h2>
<p>Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For example, Cygwin has the <code>mingw64-i686-gcc</code> and <code>mingw64-x86_64-gcc</code> packages for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives like Ubuntu have the <code>mingw-w64</code> package for both.</p>
<p>GLFW has CMake toolchain files in the <code>CMake/</code> directory that allow for easy cross-compilation of Windows binaries. To use these files you need to add a special parameter when generating the project files or makefiles: </p>
<pre class="fragment">cmake -DCMAKE_TOOLCHAIN_FILE=&lt;toolchain-file&gt; .
</pre><p>The exact toolchain file to use depends on the prefix used by the MinGW or MinGW-w64 binaries on your system. You can usually see this in the /usr directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages have <code>/usr/x86_64-w64-mingw32</code> for the 64-bit compilers, so the correct invocation would be: </p>
<pre class="fragment">cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
</pre><p>For more details see the article <a href="http://www.paraview.org/Wiki/CMake_Cross_Compiling">CMake Cross Compiling</a> on the CMake wiki.</p>
<h2><a class="anchor" id="compile_deps_xcode"></a>
Dependencies using Xcode on OS X</h2>
<p>Xcode contains all necessary tools except for CMake. The necessary headers and libraries are included in the core OS frameworks. Xcode can be downloaded from the Mac App Store or from the ADC Member Center.</p>
<h2><a class="anchor" id="compile_deps_x11"></a>
Dependencies using Linux and X11</h2>
<p>To compile GLFW for X11, you need to have the X11 and OpenGL header packages installed, as well as the basic development tools like GCC and make. For example, on Ubuntu and other distributions based on Debian GNU/Linux, you need to install the <code>xorg-dev</code> and <code>libglu1-mesa-dev</code> packages. The former pulls in all X.org header packages and the latter pulls in the Mesa OpenGL and GLU packages. GLFW itself doesn't need or use GLU, but some of the examples do. Note that using header files and libraries from Mesa during compilation <em>will not</em> tie your binaries to the Mesa implementation of OpenGL.</p>
<h1><a class="anchor" id="compile_cmake"></a>
Generating files with CMake</h1>
<p>Once you have all necessary dependencies it is time to generate the project files or makefiles for your development environment. CMake needs to know two paths for this: the path to the <em>root</em> directory of the GLFW source tree (i.e. <em>not</em> the <code>src</code> subdirectory) and the target path for the generated files and compiled binaries. If these are the same, it is called an in-tree build, otherwise it is called an out-of-tree build.</p>
<p>One of several advantages of out-of-tree builds is that you can generate files and compile for different development environments using a single source tree.</p>
<h2><a class="anchor" id="compile_cmake_cli"></a>
Generating files with the CMake command-line tool</h2>
<p>To make an in-tree build, enter the <em>root</em> directory of the GLFW source tree (i.e. <em>not</em> the <code>src</code> subdirectory) and run CMake. The current directory is used as target path, while the path provided as an argument is used to find the source tree. </p>
<pre class="fragment">cd &lt;glfw-root-dir&gt;
cmake .
</pre><p>To make an out-of-tree build, make another directory, enter it and run CMake with the (relative or absolute) path to the root of the source tree as an argument. </p>
<pre class="fragment">cd &lt;glfw-root-dir&gt;
mkdir build
cd build
cmake ..
</pre><h2><a class="anchor" id="compile_cmake_gui"></a>
Generating files with the CMake GUI</h2>
<p>If you are using the GUI version, choose the root of the GLFW source tree as source location and the same directory or another, empty directory as the destination for binaries. Choose <em>Configure</em>, change any options you wish to, <em>Configure</em> again to let the changes take effect and then <em>Generate</em>.</p>
<h1><a class="anchor" id="compile_options"></a>
CMake options</h1>
<p>The CMake files for GLFW provide a number of options, although not all are available on all supported platforms. Some of these are de facto standards among CMake users and so have no <code>GLFW_</code> prefix.</p>
<p>If you are using the GUI version of CMake, these are listed and can be changed from there. If you are using the command-line version, use the <code>ccmake</code> tool. Some package systems like Ubuntu and other distributions based on Debian GNU/Linux have this tool in a separate <code>cmake-curses-gui</code> package.</p>
<h2><a class="anchor" id="compile_options_shared"></a>
Shared CMake options</h2>
<p><code>BUILD_SHARED_LIBS</code> determines whether GLFW is built as a static library or as a DLL / shared library / dynamic library.</p>
<p><code>LIB_SUFFIX</code> affects where the GLFW shared /dynamic library is installed. If it is empty, it is installed to <code>${CMAKE_INSTALL_PREFIX}/lib</code>. If it is set to <code>64</code>, it is installed to <code>${CMAKE_INSTALL_PREFIX}/lib64</code>.</p>
<p><code>GLFW_CLIENT_LIBRARY</code> determines which client API library to use. If set to <code>opengl</code> the OpenGL library is used, if set to <code>glesv1</code> for the OpenGL ES 1.x library is used, or if set to <code>glesv2</code> the OpenGL ES 2.0 library is used. The selected library and its header files must be present on the system for this to work.</p>
<p><code>GLFW_BUILD_EXAMPLES</code> determines whether the GLFW examples are built along with the library.</p>
<p><code>GLFW_BUILD_TESTS</code> determines whether the GLFW test programs are built along with the library.</p>
<p><code>GLFW_BUILD_DOCS</code> determines whether the GLFW documentation is built along with the library.</p>
<h2><a class="anchor" id="compile_options_osx"></a>
OS X specific CMake options</h2>
<p><code>GLFW_USE_CHDIR</code> determines whether <code>glfwInit</code> changes the current directory of bundled applications to the <code>Contents/Resources</code> directory.</p>
<p><code>GLFW_USE_MENUBAR</code> determines whether the first call to <code>glfwCreateWindow</code> sets up a minimal menu bar.</p>
<p><code>GLFW_BUILD_UNIVERSAL</code> determines whether to build Universal Binaries.</p>
<h2><a class="anchor" id="compile_options_win32"></a>
Windows specific CMake options</h2>
<p><code>USE_MSVC_RUNTIME_LIBRARY_DLL</code> determines whether to use the DLL version or the static library version of the Visual C++ runtime library. If set to <code>ON</code>, the DLL version of the Visual C++ library is used. It is recommended to set this to <code>ON</code>, as this keeps the executable smaller and benefits from security and bug fix updates of the Visual C++ runtime.</p>
<p><code>GLFW_USE_DWM_SWAP_INTERVAL</code> determines whether the swap interval is set even when DWM compositing is enabled. If this is <code>ON</code>, the swap interval is set even if DWM is enabled. It is recommended to set this to <code>OFF</code>, as doing otherwise can lead to severe jitter.</p>
<p><code>GLFW_USE_OPTIMUS_HPG</code> determines whether to export the <code>NvOptimusEnablement</code> symbol, which forces the use of the high-performance GPU on nVidia Optimus systems.</p>
<h2><a class="anchor" id="compile_options_egl"></a>
EGL specific CMake options</h2>
<p><code>GLFW_USE_EGL</code> determines whether to use EGL instead of the platform-specific context creation API. Note that EGL is not yet provided on all supported platforms.</p>
<h1><a class="anchor" id="compile_manual"></a>
Compiling GLFW manually</h1>
<p>If you wish to compile GLFW without its CMake build environment then you will have to do at least some of the platform detection yourself. GLFW needs a number of configuration macros to be defined in order to know what it's being compiled for and has many optional, platform-specific ones for various features.</p>
<p>When building with CMake, the <code>glfw_config.h</code> configuration header is generated based on the current platform and CMake options. The GLFW CMake environment defines <code>_GLFW_USE_CONFIG_H</code>, which causes this header to be included by <code>internal.h</code>. Without this macro, GLFW will expect the necessary configuration macros to be defined on the command-line.</p>
<p>Three macros <em>must</em> be defined when compiling GLFW: one for selecting the window creation API, one selecting the context creation API and one client library. Exactly one of each kind must be defined for GLFW to compile and link.</p>
<p>The window creation API is used to create windows, handle input, monitors, gamma ramps and clipboard. The options are:</p>
<ul>
<li><code>_GLFW_COCOA</code> to use the Cocoa frameworks</li>
<li><code>_GLFW_WIN32</code> to use the Win32 API</li>
<li><code>_GLFW_X11</code> to use the X Window System</li>
</ul>
<p>The context creation API is used to enumerate pixel formats / framebuffer configurations and to create contexts. The options are:</p>
<ul>
<li><code>_GLFW_NSGL</code> to use the Cocoa OpenGL framework</li>
<li><code>_GLFW_WGL</code> to use the Win32 WGL API</li>
<li><code>_GLFW_GLX</code> to use the X11 GLX API</li>
<li><code>_GLFW_EGL</code> to use the EGL API (experimental)</li>
</ul>
<p>The client library is the one providing the OpenGL or OpenGL ES API, which is used by GLFW to probe the created context. This is not the same thing as the client API, as many desktop OpenGL client libraries now expose the OpenGL ES API through extensions. The options are:</p>
<ul>
<li><code>_GLFW_USE_OPENGL</code> for the desktop OpenGL (opengl32.dll, libGL.so or OpenGL.framework)</li>
<li><code>_GLFW_USE_GLESV1</code> for OpenGL ES 1.x (experimental)</li>
<li><code>_GLFW_USE_GLESV2</code> for OpenGL ES 2.x (experimental)</li>
</ul>
<p>Note that <code>_GLFW_USE_GLESV1</code> and <code>_GLFW_USE_GLESV2</code> may only be used with EGL, as the other context creation APIs do not interface with OpenGL ES client libraries.</p>
<p>If you are building GLFW as a shared library / dynamic library / DLL then you must also define <code>_GLFW_BUILD_DLL</code>. Otherwise, you may not define it.</p>
<p>If you are using the X11 window creation API then you <em>must</em> also select an entry point retrieval mechanism.</p>
<ul>
<li><code>_GLFW_HAS_GLXGETPROCADDRESS</code> to use <code>glXGetProcAddress</code> (recommended)</li>
<li><code>_GLFW_HAS_GLXGETPROCADDRESSARB</code> to use <code>glXGetProcAddressARB</code> (legacy)</li>
<li><code>_GLFW_HAS_GLXGETPROCADDRESSEXT</code> to use <code>glXGetProcAddressEXT</code> (legacy)</li>
<li><code>_GLFW_HAS_DLOPEN</code> to do manual retrieval with <code>dlopen</code> (fallback)</li>
</ul>
<p>If you are using the Cocoa window creation API, the following options are available:</p>
<ul>
<li><code>_GLFW_USE_CHDIR</code> to <code>chdir</code> to the <code>Resources</code> subdirectory of the application bundle during <a class="el" href="group__init.html#ga317aac130a235ab08c6db0834907d85e">glfwInit</a> (recommended)</li>
<li><code>_GLFW_USE_MENUBAR</code> to create and populate the menu bar when the first window is created (recommended) </li>
</ul>
</div></div><!-- contents -->
<address class="footer">
<p>
Last update on Tue Dec 31 2013 for GLFW 3.0.4
</p>
</address>
</body>
</html>