aboutsummaryrefslogtreecommitdiff
path: root/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/build_guide.html
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/build_guide.html')
-rw-r--r--contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/build_guide.html192
1 files changed, 192 insertions, 0 deletions
diff --git a/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/build_guide.html b/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/build_guide.html
new file mode 100644
index 0000000..0c47ff7
--- /dev/null
+++ b/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/build_guide.html
@@ -0,0 +1,192 @@
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<meta http-equiv="X-UA-Compatible" content="IE=9"/>
7<meta name="generator" content="Doxygen 1.9.2"/>
8<title>GLFW: Building applications</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16<link href="extra.css" rel="stylesheet" type="text/css"/>
17</head>
18<body>
19<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
20<div id="titlearea">
21 <div class="glfwheader">
22 <a href="https://www.glfw.org/" id="glfwhome">GLFW</a>
23 <ul class="glfwnavbar">
24 <li><a href="https://www.glfw.org/documentation.html">Documentation</a></li>
25 <li><a href="https://www.glfw.org/download.html">Download</a></li>
26 <li><a href="https://www.glfw.org/community.html">Community</a></li>
27 </ul>
28 </div>
29</div>
30<!-- end header part -->
31<!-- Generated by Doxygen 1.9.2 -->
32<script type="text/javascript">
33/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
34var searchBox = new SearchBox("searchBox", "search",'Search','.html');
35/* @license-end */
36</script>
37<script type="text/javascript" src="menudata.js"></script>
38<script type="text/javascript" src="menu.js"></script>
39<script type="text/javascript">
40/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
41$(function() {
42 initMenu('',true,false,'search.php','Search');
43 $(document).ready(function() { init_search(); });
44});
45/* @license-end */
46</script>
47<div id="main-nav"></div>
48<!-- window showing the filter options -->
49<div id="MSearchSelectWindow"
50 onmouseover="return searchBox.OnSearchSelectShow()"
51 onmouseout="return searchBox.OnSearchSelectHide()"
52 onkeydown="return searchBox.OnSearchSelectKey(event)">
53</div>
54
55<!-- iframe showing the search results (closed by default) -->
56<div id="MSearchResultsWindow">
57<iframe src="javascript:void(0)" frameborder="0"
58 name="MSearchResults" id="MSearchResults">
59</iframe>
60</div>
61
62</div><!-- top -->
63<div><div class="header">
64 <div class="headertitle"><div class="title">Building applications </div></div>
65</div><!--header-->
66<div class="contents">
67<div class="toc"><h3>Table of Contents</h3>
68<ul><li class="level1"><a href="#build_include">Including the GLFW header file</a><ul><li class="level2"><a href="#build_macros">GLFW header option macros</a></li>
69</ul>
70</li>
71<li class="level1"><a href="#build_link">Link with the right libraries</a><ul><li class="level2"><a href="#build_link_win32">With MinGW or Visual C++ on Windows</a></li>
72<li class="level2"><a href="#build_link_cmake_source">With CMake and GLFW source</a></li>
73<li class="level2"><a href="#build_link_cmake_package">With CMake and installed GLFW binaries</a></li>
74<li class="level2"><a href="#build_link_pkgconfig">With makefiles and pkg-config on Unix</a></li>
75<li class="level2"><a href="#build_link_xcode">With Xcode on macOS</a></li>
76<li class="level2"><a href="#build_link_osx">With command-line on macOS</a></li>
77</ul>
78</li>
79</ul>
80</div>
81<div class="textblock"><p >This is about compiling and linking applications that use GLFW. For information on how to write such applications, start with the <a class="el" href="quick_guide.html">introductory tutorial</a>. For information on how to compile the GLFW library itself, see <a class="el" href="compile_guide.html">Compiling GLFW</a>.</p>
82<p >This is not a tutorial on compilation or linking. It assumes basic understanding of how to compile and link a C program as well as how to use the specific compiler of your chosen development environment. The compilation and linking process should be explained in your C programming material and in the documentation for your development environment.</p>
83<h1><a class="anchor" id="build_include"></a>
84Including the GLFW header file</h1>
85<p >You should include the GLFW header in the source files where you use OpenGL or GLFW.</p>
86<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="glfw3_8h.html">GLFW/glfw3.h</a>&gt;</span></div>
87<div class="ttc" id="aglfw3_8h_html"><div class="ttname"><a href="glfw3_8h.html">glfw3.h</a></div><div class="ttdoc">The header of the GLFW 3 API.</div></div>
88</div><!-- fragment --><p >This header defines all the constants and declares all the types and function prototypes of the GLFW API. By default it also includes the OpenGL header from your development environment. See <a class="el" href="build_guide.html#build_macros">option macros</a> below for how to select OpenGL ES headers and more.</p>
89<p >The GLFW header also defines any platform-specific macros needed by your OpenGL header, so that it can be included without needing any window system headers.</p>
90<p >It does this only when needed, so if window system headers are included, the GLFW header does not try to redefine those symbols. The reverse is not true, i.e. <code>windows.h</code> cannot cope if any Win32 symbols have already been defined.</p>
91<p >In other words:</p>
92<ul>
93<li>Use the GLFW header to include OpenGL or OpenGL ES headers portably</li>
94<li>Do not include window system headers unless you will use those APIs directly</li>
95<li>If you do need such headers, include them before the GLFW header</li>
96</ul>
97<p >If you are using an OpenGL extension loading library such as <a href="https://github.com/Dav1dde/glad">glad</a>, the extension loader header should be included before the GLFW one. GLFW attempts to detect any OpenGL or OpenGL ES header or extension loader header included before it and will then disable the inclusion of the default OpenGL header. Most extension loaders also define macros that disable similar headers below it.</p>
98<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;glad/gl.h&gt;</span></div>
99<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="glfw3_8h.html">GLFW/glfw3.h</a>&gt;</span></div>
100</div><!-- fragment --><p >Both of these mechanisms depend on the extension loader header defining a known macro. If yours doesn't or you don't know which one your users will pick, the <a class="el" href="build_guide.html#GLFW_INCLUDE_NONE">GLFW_INCLUDE_NONE</a> macro will explicitly to prevent the GLFW header from including the OpenGL header. This will also allow you to include the two headers in any order.</p>
101<div class="fragment"><div class="line"><span class="preprocessor">#define GLFW_INCLUDE_NONE</span></div>
102<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="glfw3_8h.html">GLFW/glfw3.h</a>&gt;</span></div>
103<div class="line"><span class="preprocessor">#include &lt;glad/gl.h&gt;</span></div>
104</div><!-- fragment --><h2><a class="anchor" id="build_macros"></a>
105GLFW header option macros</h2>
106<p >These macros may be defined before the inclusion of the GLFW header and affect its behavior.</p>
107<p ><a class="anchor" id="GLFW_DLL"></a><b>GLFW_DLL</b> is required on Windows when using the GLFW DLL, to tell the compiler that the GLFW functions are defined in a DLL.</p>
108<p >The following macros control which OpenGL or OpenGL ES API header is included. Only one of these may be defined at a time.</p>
109<dl class="section note"><dt>Note</dt><dd>GLFW does not provide any of the API headers mentioned below. They are provided by your development environment or your OpenGL, OpenGL ES or Vulkan SDK, and most of them can be downloaded from the <a href="https://www.khronos.org/registry/">Khronos Registry</a>.</dd></dl>
110<p><a class="anchor" id="GLFW_INCLUDE_GLCOREARB"></a><b>GLFW_INCLUDE_GLCOREARB</b> makes the GLFW header include the modern <code>GL/glcorearb.h</code> header (<code>OpenGL/gl3.h</code> on macOS) instead of the regular OpenGL header.</p>
111<p ><a class="anchor" id="GLFW_INCLUDE_ES1"></a><b>GLFW_INCLUDE_ES1</b> makes the GLFW header include the OpenGL ES 1.x <code>GLES/gl.h</code> header instead of the regular OpenGL header.</p>
112<p ><a class="anchor" id="GLFW_INCLUDE_ES2"></a><b>GLFW_INCLUDE_ES2</b> makes the GLFW header include the OpenGL ES 2.0 <code>GLES2/gl2.h</code> header instead of the regular OpenGL header.</p>
113<p ><a class="anchor" id="GLFW_INCLUDE_ES3"></a><b>GLFW_INCLUDE_ES3</b> makes the GLFW header include the OpenGL ES 3.0 <code>GLES3/gl3.h</code> header instead of the regular OpenGL header.</p>
114<p ><a class="anchor" id="GLFW_INCLUDE_ES31"></a><b>GLFW_INCLUDE_ES31</b> makes the GLFW header include the OpenGL ES 3.1 <code>GLES3/gl31.h</code> header instead of the regular OpenGL header.</p>
115<p ><a class="anchor" id="GLFW_INCLUDE_ES32"></a><b>GLFW_INCLUDE_ES32</b> makes the GLFW header include the OpenGL ES 3.2 <code>GLES3/gl32.h</code> header instead of the regular OpenGL header.</p>
116<p ><a class="anchor" id="GLFW_INCLUDE_NONE"></a><b>GLFW_INCLUDE_NONE</b> makes the GLFW header not include any OpenGL or OpenGL ES API header. This is useful in combination with an extension loading library.</p>
117<p >If none of the above inclusion macros are defined, the standard OpenGL <code>GL/gl.h</code> header (<code>OpenGL/gl.h</code> on macOS) is included, unless GLFW detects the inclusion guards of any OpenGL, OpenGL ES or extension loader header it knows about.</p>
118<p >The following macros control the inclusion of additional API headers. Any number of these may be defined simultaneously, and/or together with one of the above macros.</p>
119<p ><a class="anchor" id="GLFW_INCLUDE_VULKAN"></a><b>GLFW_INCLUDE_VULKAN</b> makes the GLFW header include the Vulkan <code>vulkan/vulkan.h</code> header in addition to any selected OpenGL or OpenGL ES header.</p>
120<p ><a class="anchor" id="GLFW_INCLUDE_GLEXT"></a><b>GLFW_INCLUDE_GLEXT</b> makes the GLFW header include the appropriate extension header for the OpenGL or OpenGL ES header selected above after and in addition to that header.</p>
121<p ><a class="anchor" id="GLFW_INCLUDE_GLU"></a><b>GLFW_INCLUDE_GLU</b> makes the header include the GLU header in addition to the header selected above. This should only be used with the standard OpenGL header and only for compatibility with legacy code. GLU has been deprecated and should not be used in new code.</p>
122<dl class="section note"><dt>Note</dt><dd>None of these macros may be defined during the compilation of GLFW itself. If your build includes GLFW and you define any these in your build files, make sure they are not applied to the GLFW sources.</dd></dl>
123<h1><a class="anchor" id="build_link"></a>
124Link with the right libraries</h1>
125<p >GLFW is essentially a wrapper of various platform-specific APIs and therefore needs to link against many different system libraries. If you are using GLFW as a shared library / dynamic library / DLL then it takes care of these links. However, if you are using GLFW as a static library then your executable will need to link against these libraries.</p>
126<p >On Windows and macOS, the list of system libraries is static and can be hard-coded into your build environment. See the section for your development environment below. On Linux and other Unix-like operating systems, the list varies but can be retrieved in various ways as described below.</p>
127<p >A good general introduction to linking is <a href="https://www.lurklurk.org/linkers/linkers.html">Beginner's Guide to Linkers</a> by David Drysdale.</p>
128<h2><a class="anchor" id="build_link_win32"></a>
129With MinGW or Visual C++ on Windows</h2>
130<p >The static version of the GLFW library is named <code>glfw3</code>. When using this version, it is also necessary to link with some libraries that GLFW uses.</p>
131<p >When using MinGW to link an application with the static version of GLFW, you must also explicitly link with <code>gdi32</code>. Other toolchains including MinGW-w64 include it in the set of default libraries along with other dependencies like <code>user32</code> and <code>kernel32</code>.</p>
132<p >The link library for the GLFW DLL is named <code>glfw3dll</code>. When compiling an application that uses the DLL version of GLFW, you need to define the <a class="el" href="build_guide.html#GLFW_DLL">GLFW_DLL</a> macro <em>before</em> any inclusion of the GLFW header. This can be done either with a compiler switch or by defining it in your source code.</p>
133<h2><a class="anchor" id="build_link_cmake_source"></a>
134With CMake and GLFW source</h2>
135<p >This section is about using CMake to compile and link GLFW along with your application. If you want to use an installed binary instead, see <a class="el" href="build_guide.html#build_link_cmake_package">With CMake and installed GLFW binaries</a>.</p>
136<p >With a few changes to your <code>CMakeLists.txt</code> you can have the GLFW source tree built along with your application.</p>
137<p >When including GLFW as part of your build, you probably don't want to build the GLFW tests, examples and documentation. To disable these, set the corresponding cache variables before adding the GLFW source tree.</p>
138<div class="fragment"><div class="line">set(GLFW_BUILD_DOCS OFF CACHE BOOL <span class="stringliteral">&quot;&quot;</span> FORCE)</div>
139<div class="line">set(GLFW_BUILD_TESTS OFF CACHE BOOL <span class="stringliteral">&quot;&quot;</span> FORCE)</div>
140<div class="line">set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL <span class="stringliteral">&quot;&quot;</span> FORCE)</div>
141</div><!-- fragment --><p >Add the root directory of the GLFW source tree to your project. This will add the <code>glfw</code> target to your project.</p>
142<div class="fragment"><div class="line">add_subdirectory(path/to/glfw)</div>
143</div><!-- fragment --><p >Once GLFW has been added, link your application against the <code>glfw</code> target. This adds the GLFW library and its link-time dependencies as it is currently configured, the include directory for the GLFW header and, when applicable, the <a class="el" href="build_guide.html#GLFW_DLL">GLFW_DLL</a> macro.</p>
144<div class="fragment"><div class="line">target_link_libraries(myapp glfw)</div>
145</div><!-- fragment --><p >Note that the <code>glfw</code> target does not depend on OpenGL, as GLFW loads any OpenGL, OpenGL ES or Vulkan libraries it needs at runtime. If your application calls OpenGL directly, instead of using a modern <a class="el" href="context_guide.html#context_glext_auto">extension loader library</a>, use the OpenGL CMake package.</p>
146<div class="fragment"><div class="line">find_package(OpenGL REQUIRED)</div>
147</div><!-- fragment --><p >If OpenGL is found, the <code>OpenGL::GL</code> target is added to your project, containing library and include directory paths. Link against this like any other library.</p>
148<div class="fragment"><div class="line">target_link_libraries(myapp OpenGL::GL)</div>
149</div><!-- fragment --><p >For a minimal example of a program and GLFW sources built with CMake, see the <a href="https://github.com/juliettef/GLFW-CMake-starter">GLFW CMake Starter</a> on GitHub.</p>
150<h2><a class="anchor" id="build_link_cmake_package"></a>
151With CMake and installed GLFW binaries</h2>
152<p >This section is about using CMake to link GLFW after it has been built and installed. If you want to build it along with your application instead, see <a class="el" href="build_guide.html#build_link_cmake_source">With CMake and GLFW source</a>.</p>
153<p >With a few changes to your <code>CMakeLists.txt</code> you can locate the package and target files generated when GLFW is installed.</p>
154<div class="fragment"><div class="line">find_package(glfw3 3.3 REQUIRED)</div>
155</div><!-- fragment --><p >Once GLFW has been added to the project, link against it with the <code>glfw</code> target. This adds the GLFW library and its link-time dependencies, the include directory for the GLFW header and, when applicable, the <a class="el" href="build_guide.html#GLFW_DLL">GLFW_DLL</a> macro.</p>
156<div class="fragment"><div class="line">target_link_libraries(myapp glfw)</div>
157</div><!-- fragment --><p >Note that the <code>glfw</code> target does not depend on OpenGL, as GLFW loads any OpenGL, OpenGL ES or Vulkan libraries it needs at runtime. If your application calls OpenGL directly, instead of using a modern <a class="el" href="context_guide.html#context_glext_auto">extension loader library</a>, use the OpenGL CMake package.</p>
158<div class="fragment"><div class="line">find_package(OpenGL REQUIRED)</div>
159</div><!-- fragment --><p >If OpenGL is found, the <code>OpenGL::GL</code> target is added to your project, containing library and include directory paths. Link against this like any other library.</p>
160<div class="fragment"><div class="line">target_link_libraries(myapp OpenGL::GL)</div>
161</div><!-- fragment --><h2><a class="anchor" id="build_link_pkgconfig"></a>
162With makefiles and pkg-config on Unix</h2>
163<p >GLFW supports <a href="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</a>, and the <code>glfw3.pc</code> pkg-config file is generated when the GLFW library is built and is installed along with it. A pkg-config file describes all necessary compile-time and link-time flags and dependencies needed to use a library. When they are updated or if they differ between systems, you will get the correct ones automatically.</p>
164<p >A typical compile and link command-line when using the static version of the GLFW library may look like this:</p>
165<div class="fragment"><div class="line">cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --static --libs glfw3)</div>
166</div><!-- fragment --><p >If you are using the shared version of the GLFW library, omit the <code>--static</code> flag.</p>
167<div class="fragment"><div class="line">cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3)</div>
168</div><!-- fragment --><p >You can also use the <code>glfw3.pc</code> file without installing it first, by using the <code>PKG_CONFIG_PATH</code> environment variable.</p>
169<div class="fragment"><div class="line">env PKG_CONFIG_PATH=path/to/glfw/src cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3)</div>
170</div><!-- fragment --><p >The dependencies do not include OpenGL, as GLFW loads any OpenGL, OpenGL ES or Vulkan libraries it needs at runtime. If your application calls OpenGL directly, instead of using a modern <a class="el" href="context_guide.html#context_glext_auto">extension loader library</a>, you should add the <code>gl</code> pkg-config package.</p>
171<div class="fragment"><div class="line">cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 gl)</div>
172</div><!-- fragment --><h2><a class="anchor" id="build_link_xcode"></a>
173With Xcode on macOS</h2>
174<p >If you are using the dynamic library version of GLFW, add it to the project dependencies.</p>
175<p >If you are using the static library version of GLFW, add it and the Cocoa, OpenGL and IOKit frameworks to the project as dependencies. They can all be found in <code>/System/Library/Frameworks</code>.</p>
176<h2><a class="anchor" id="build_link_osx"></a>
177With command-line on macOS</h2>
178<p >It is recommended that you use <a class="el" href="build_guide.html#build_link_pkgconfig">pkg-config</a> when building from the command line on macOS. That way you will get any new dependencies added automatically. If you still wish to build manually, you need to add the required frameworks and libraries to your command-line yourself using the <code>-l</code> and <code>-framework</code> switches.</p>
179<p >If you are using the dynamic GLFW library, which is named <code>libglfw.3.dylib</code>, do:</p>
180<div class="fragment"><div class="line">cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit</div>
181</div><!-- fragment --><p >If you are using the static library, named <code>libglfw3.a</code>, substitute <code>-lglfw3</code> for <code>-lglfw</code>.</p>
182<p >Note that you do not add the <code>.framework</code> extension to a framework when linking against it from the command-line.</p>
183<dl class="section note"><dt>Note</dt><dd>Your machine may have <code>libGL.*.dylib</code> style OpenGL library, but that is for the X Window System and will not work with the macOS native version of GLFW. </dd></dl>
184</div></div><!-- contents -->
185</div><!-- PageDoc -->
186<address class="footer">
187<p>
188Last update on Thu Oct 28 2021 for GLFW 3.3.5
189</p>
190</address>
191</body>
192</html>