summaryrefslogtreecommitdiffstats
path: root/develop/_l_b_compiling.html
blob: 3eaf8663c26fbf5b2b211c7859395e19c09f541e (plain)
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!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.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>HDF5: Compiling HDF5 Applications</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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="hdf5doxy.css" rel="stylesheet" type="text/css">
<!-- <link href="hdf5doxy.css" rel="stylesheet" type="text/css"/>
 -->
<script type="text/javascript" src="hdf5_navtree_hacks.js"></script>
</head>
<body>
<div style="background:#FFDDDD;font-size:120%;text-align:center;margin:0;padding:5px">Please, help us to better serve our user community by answering the following short survey:  <a href="https://www.hdfgroup.org/website-survey/">https://www.hdfgroup.org/website-survey/</a></div>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="HDFG-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="https://www.hdfgroup.org">HDF5</a>
   &#160;<span id="projectnumber">1.15.0.2a43372</span>
   </div>
   <div id="projectbrief">API Reference</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               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.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_l_b_compiling.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</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 class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Compiling HDF5 Applications </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Navigate back: <a class="el" href="index.html">Main</a> / <a class="el" href="_getting_started.html">Getting Started with HDF5</a> / <a class="el" href="_learn_basics.html">Learning the Basics</a> </p><hr  />
<h1><a class="anchor" id="secLBCompiling"></a>
Tools and Instructions on Compiling</h1>
<p>Compiling applications to use the HDF5 Library can be as simple as executing: </p><div class="fragment"><div class="line">h5cc -o myprog myprog.c</div>
</div><!-- fragment --><p>As an application's file base evolves, there are better solutions using autotools and makefiles or CMake and CMakeLists.txt files. Many tutorials and references can be found with a simple search.</p>
<p>This tutorial section will discuss the use of compile scripts on Linux. See the <a class="el" href="_l_b_compiling.html#secLBCompilingVS">Using Visual Studio</a> section for compiling with Visual Studio.</p>
<h1><a class="anchor" id="secLBCompilingLinux"></a>
Compile Scripts</h1>
<p>When the library is built, the following compile scripts are included: </p><ul>
<li>h5cc: compile script for HDF5 C programs </li>
<li>h5fc: compile script for HDF5 F90 programs </li>
<li>h5c++: compile script for HDF5 C++ programs</li>
</ul>
<p>These scripts are easilye used to compile single file applications, such as those included in the tutorial. </p><table class="doxtable">
<tr>
<th><b>Warning</b>  </th><td>The h5cc/h5fc/h5c++ compile scripts are included when building with configure. Versions of these compile scripts have also been added to CMake for Linux ONLY. The CMake versions rely on pkgconfig files.   </td></tr>
</table>
<h4>Examples of Using the Unix Compile Scripts:</h4>
<p>Following are examples of compiling and running an application with the Unix compile scripts: </p><div class="fragment"><div class="line">h5fc myprog.f90</div>
<div class="line">./a.out</div>
<div class="line"> </div>
<div class="line">h5cc -o myprog myprog.c</div>
<div class="line">./myprog </div>
</div><!-- fragment --><p>To see how the libraries linked in with a compile script were configured and built, use the -showconfig option. For example, if using h5cc type: </p><div class="fragment"><div class="line">h5cc -showconfig</div>
</div><!-- fragment --><h4>Detailed Description of Unix Compile Scripts:</h4>
<p>The h5cc, h5c++, and h5fc compile scripts come with the HDF5 binary distributions (include files, libraries, and utilities) for the platforms we support. The h5c++ and h5fc utilities are ONLY present if the library was built with C++ and Fortran.</p>
<h1><a class="anchor" id="secLBCompilingVS"></a>
Using Visual Studio</h1>
<ol type="1">
<li>If you are building on 64-bit Windows, find the "Platform" dropdown and select "x64". Also select the correct Configuration (Debug, Release, RelWithDebInfo, etc)</li>
<li><p class="startli">Set up path for external headers</p>
<p class="startli">The HDF5 install path settings will need to be in the project property sheets per project. Go to "Project" and select "Properties", find "Configuration Properties", and then "C/C++".</p>
<p class="startli">2.1 Add the header path to the "Additional Include Directories" setting. Under "C/C++" find "General" and select "Additional Include Directories". Select "Edit" from the dropdown and add the HDF5 install/include path to the list. (Ex: "C:\Program Files\HDF_Group\HDF5\1.10.9\include")</p>
<p class="startli">2.2 Building applications with the dynamic/shared <a class="el" href="namespacehdf5.html">hdf5</a> libraries requires that the "H5_BUILT_AS_DYNAMIC_LIB" compile definition be used. Under "C/C++" find "Preprocessor" and select "Preprocessor Definitions". Select "Edit" from the dropdown and add "H5_BUILT_AS_DYNAMIC_LIB" to the list.</p>
</li>
<li><p class="startli">Set up path for external libraries</p>
<p class="startli">The HDF5 install path/lib settings will need to be in the project property sheets per project. Go to "Project" and select "Properties", find "Configuration Properties", and then "Linker".</p>
<p class="startli">3.1 Add the libraries to the "Additional Dependencies" setting. Under "Linker" find "Input" and select "Additional Dependencies". Select "Edit" from the dropdown and add the required HDF5 install/lib path to the list. (Ex: "C:\Program Files\HDF_Group\HDF5\1.10.9\lib\hdf5.lib")</p>
<p class="startli">3.2 For static builds, the external libraries should be added. For example, to compile a C++ application, enter: libhdf5_cpp.lib libhdf5.lib libz.lib libszaec.lib libaec.lib</p>
</li>
</ol>
<h1><a class="anchor" id="secLBCompilingLibs"></a>
HDF5 Libraries</h1>
<p>Following are the libraries included with HDF5. Whether you are using the Unix compile scripts or Makefiles, or are compiling on Windows, these libraries are or may need to be specified. The order they are specified is important on Linux:</p>
<table class="doxtable">
<caption>HDF5 Static Libraries</caption>
<tr>
<th>Library </th><th>Linux Name </th><th>Mac Name </th><th>Windows Name  </th></tr>
<tr>
<td><div class="fragment"><div class="line">HDF5 High Level C++ APIs </div>
<div class="line">HDF5 C++ Library  </div>
<div class="line">HDF5 High Level Fortran APIs</div>
<div class="line">HDF5 Fortran Library</div>
<div class="line">HDF5 High Level C APIs</div>
<div class="line">HDF5 C Library</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libhdf5_hl_cpp.a</div>
<div class="line">libhdf5_cpp.a</div>
<div class="line">libhdf5hl_fortran.a</div>
<div class="line">libhdf5_fortran.a</div>
<div class="line">libhdf5_hl.a</div>
<div class="line">libhdf5.a</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libhdf5_hl_cpp.a</div>
<div class="line">libhdf5_cpp.a</div>
<div class="line">libhdf5hl_fortran.a</div>
<div class="line">libhdf5_fortran.a</div>
<div class="line">libhdf5_hl.a</div>
<div class="line">libhdf5.a</div>
</div><!-- fragment -->  </td><td><em>Windows</em> <div class="fragment"><div class="line">libhdf5_hl_cpp.lib</div>
<div class="line">libhdf5_cpp.lib</div>
<div class="line">libhdf5hl_fortran.lib</div>
<div class="line">libhdf5_fortran.lib</div>
<div class="line">libhdf5_hl.lib</div>
<div class="line">libhdf5.lib</div>
</div><!-- fragment -->  </td></tr>
</table>
<table class="doxtable">
<caption>HDF5 Shared Libraries</caption>
<tr>
<th>Library </th><th>Linux Name </th><th>Mac Name </th><th>Windows Name  </th></tr>
<tr>
<td><div class="fragment"><div class="line">HDF5 High Level C++ APIs </div>
<div class="line">HDF5 C++ Library  </div>
<div class="line">HDF5 High Level Fortran APIs</div>
<div class="line">HDF5 Fortran Library</div>
<div class="line">HDF5 High Level C APIs</div>
<div class="line">HDF5 C Library</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libhdf5_hl_cpp.so</div>
<div class="line">libhdf5_cpp.so</div>
<div class="line">libhdf5hl_fortran.so</div>
<div class="line">libhdf5_fortran.so</div>
<div class="line">libhdf5_hl.so</div>
<div class="line">libhdf5.so</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libhdf5_hl_cpp.dylib</div>
<div class="line">libhdf5_cpp.dylib</div>
<div class="line">libhdf5hl_fortran.dylib</div>
<div class="line">libhdf5_fortran.dylib</div>
<div class="line">libhdf5_hl.dylib</div>
<div class="line">libhdf5.dylib</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">hdf5_hl_cpp.lib</div>
<div class="line">hdf5_cpp.lib</div>
<div class="line">hdf5hl_fortran.lib</div>
<div class="line">hdf5_fortran.lib</div>
<div class="line">hdf5_hl.lib</div>
<div class="line"><a class="code" href="namespacehdf5.html">hdf5</a>.lib</div>
<div class="ttc" id="anamespacehdf5_html"><div class="ttname"><a href="namespacehdf5.html">hdf5</a></div><div class="ttdef"><b>Definition:</b> HDF5.F90:26</div></div>
</div><!-- fragment -->  </td></tr>
</table>
<table class="doxtable">
<caption>External Libraries</caption>
<tr>
<th>Library </th><th>Linux Name </th><th>Mac Name </th><th>Windows Name  </th></tr>
<tr>
<td><div class="fragment"><div class="line">SZIP Compression Library</div>
<div class="line">SZIP Compression Library</div>
<div class="line">ZLIB or DEFLATE Compression Library</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libszaec.a</div>
<div class="line">libaec.a</div>
<div class="line">libz.a</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libszaec.a</div>
<div class="line">libaec.a</div>
<div class="line">libz.a</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">libszaec.lib</div>
<div class="line">libaec.lib</div>
<div class="line">libz.lib</div>
</div><!-- fragment -->   </td></tr>
</table>
<p>The pre-compiled binaries, in particular, are built (if at all possible) with these libraries as well as with SZIP and ZLIB. If using shared libraries you may need to add the path to the library to LD_LIBRARY_PATH on Linux or on WINDOWS you may need to add the path to the bin folder to PATH.</p>
<h1><a class="anchor" id="secLBCompilingCMake"></a>
Compiling an Application with CMake</h1>
<h2><a class="anchor" id="subsecLBCompilingCMakeScripts"></a>
CMake Scripts for Building Applications</h2>
<p>Simple scripts are provided for building applications with different languages and options. See <a href="https://confluence.hdfgroup.org/display/support/CMake+Scripts+for+Building+Applications">CMake Scripts for Building Applications</a>.</p>
<p>For a more complete script (and to help resolve issues) see the script provided with the HDF5 Examples project.</p>
<h2><a class="anchor" id="subsecLBCompilingCMakeExamples"></a>
HDF5 Examples</h2>
<p>The installed HDF5 can be verified by compiling the HDF5 Examples project, included with the CMake built HDF5 binaries in the share folder or you can go to the <a href="https://github.com/HDFGroup/hdf5-examples">HDF5 Examples</a> github repository.</p>
<p>Go into the share directory and follow the instructions in USING_CMake_examples.txt to build the examples.</p>
<p>In general, users must first set the HDF5_ROOT environment variable to the installed location of the CMake configuration files for HDF5. For example, on Windows the following path might be set:</p>
<div class="fragment"><div class="line">HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/1.N.N</div>
</div><!-- fragment --><h2><a class="anchor" id="subsecLBCompilingCMakeTroubless"></a>
Troubleshooting CMake</h2>
<h4>How do you use find_package with HDF5?</h4>
<p>To use find_package you will first need to make sure that HDF5_ROOT is set correctly. For setting this environment variable see the Preconditions in the USING_HDF5_CMake.txt file in the share directory.</p>
<p>See the CMakeLists.txt file provided with these examples for how to use find_package with HDF5.</p>
<p>Please note that the find_package invocation changed to require "shared" or "static": </p><div class="fragment"><div class="line">FIND_PACKAGE(HDF5 COMPONENTS C HL NO_MODULE REQUIRED shared)</div>
<div class="line">FIND_PACKAGE(HDF5 COMPONENTS C HL NO_MODULE REQUIRED <span class="keyword">static</span>)  </div>
</div><!-- fragment --><p>Previously, the find_package invocation was: </p><div class="fragment"><div class="line">FIND_PACKAGE(HDF5 COMPONENTS C HL NO_MODULE REQUIRED)</div>
</div><!-- fragment --><h4>My platform/compiler is not included. Can I still use the configuration files?</h4>
<p>Yes, you can but you will have to edit the HDF5_Examples.cmake file and update the variable: </p><div class="fragment"><div class="line">CTEST_CMAKE_GENERATOR  </div>
</div><!-- fragment --><p>The generators for your platform can be seen by typing: </p><div class="fragment"><div class="line">cmake --help</div>
</div><!-- fragment --><h4>What do I do if the build fails?</h4>
<p>I received an error during the build and the application binary is not in the build directory as I expected. How do I determine what the problem is?</p>
<p>If the error is not clear, then the first thing you may want to do is replace the -V (Dash Uppercase Vee) option for ctest in the build script to -VV (Dash Uppercase Vee Uppercase Vee). Then remove the build directory and re-run the build script. The output should be more verbose.</p>
<p>If the error is still not clear, then check the log files. You will find those in the build directory. For example, on Unix the log files will be in: </p><div class="fragment"><div class="line">build/Testing/Temporary/  </div>
</div><!-- fragment --><p> There are log files for the configure, test, and build.</p>
<hr  />
<p> Navigate back: <a class="el" href="index.html">Main</a> / <a class="el" href="_getting_started.html">Getting Started with HDF5</a> / <a class="el" href="_learn_basics.html">Learning the Basics</a> </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>