summaryrefslogtreecommitdiff
path: root/doc/html/stacktrace/configuration_and_build.html
blob: 1b8de87ed3d95cf5c828214d29615f95469c527d (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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Configuration and Build</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../stacktrace.html" title="Chapter&#160;37.&#160;Boost.Stacktrace 1.0">
<link rel="prev" href="getting_started.html" title="Getting Started">
<link rel="next" href="acknowledgements.html" title="Acknowledgements">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="getting_started.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../stacktrace.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="stacktrace.configuration_and_build"></a><a class="link" href="configuration_and_build.html" title="Configuration and Build">Configuration and Build</a>
</h2></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="section"><a href="configuration_and_build.html#stacktrace.configuration_and_build.mingw_and_mingw_w64_specific_not">MinGW
      and MinGW-w64 specific notes</a></span></dt></dl></div>
<p>
      By default Boost.Stacktrace is a header-only library, but you may change that
      and use the following macros to improve build times or to be able to tune library
      without recompiling your project:
    </p>
<div class="table">
<a name="stacktrace.configuration_and_build.linkmacro"></a><p class="title"><b>Table&#160;37.1.&#160;Link macros</b></p>
<div class="table-contents"><table class="table" summary="Link macros">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Macro name
              </p>
            </th>
<th>
              <p>
                Effect
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                <span class="bold"><strong>BOOST_STACKTRACE_LINK</strong></span>
              </p>
            </td>
<td>
              <p>
                Disable header-only build and require linking with shared or static
                library that contains the tracing implementation. If <span class="bold"><strong>BOOST_ALL_DYN_LINK</strong></span>
                is defined, then link with shared library.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <span class="bold"><strong>BOOST_STACKTRACE_DYN_LINK</strong></span>
              </p>
            </td>
<td>
              <p>
                Disable header-only build and require linking with shared library
                that contains tracing implementation.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
      In header only mode library could be tuned by macro. If one of the link macro
      from above is defined, you have to manually link with one of the libraries:
    </p>
<div class="table">
<a name="stacktrace.configuration_and_build.libconfig"></a><p class="title"><b>Table&#160;37.2.&#160;Config</b></p>
<div class="table-contents"><table class="table" summary="Config">
<colgroup>
<col>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Macro name or default
              </p>
            </th>
<th>
              <p>
                Library
              </p>
            </th>
<th>
              <p>
                Effect
              </p>
            </th>
<th>
              <p>
                Platforms
              </p>
            </th>
<th>
              <p>
                Uses debug information <a href="#ftn.stacktrace.configuration_and_build.f0" class="footnote" name="stacktrace.configuration_and_build.f0"><sup class="footnote">[a]</sup></a>
              </p>
            </th>
<th>
              <p>
                Uses dynamic exports information <a href="#ftn.stacktrace.configuration_and_build.f1" class="footnote" name="stacktrace.configuration_and_build.f1"><sup class="footnote">[b]</sup></a>
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                <span class="emphasis"><em>default for MSVC, Intel on Windows, MinGW-w64</em></span>
                / <span class="bold"><strong>BOOST_STACKTRACE_USE_WINDBG</strong></span>
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>boost_stacktrace_windbg</strong></span>
              </p>
            </td>
<td>
              <p>
                Uses COM to show debug info. May require linking with <span class="bold"><strong>ole32</strong></span>
                and <span class="bold"><strong>dbgeng</strong></span>.
              </p>
            </td>
<td>
              <p>
                MSVC, MinGW-w64, Intel on Windows
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
<td>
              <p>
                no
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <span class="emphasis"><em>default for other platforms</em></span>
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>boost_stacktrace_basic</strong></span>
              </p>
            </td>
<td>
              <p>
                Uses compiler intrinsics to collect stacktrace and if possible <code class="computeroutput"><span class="special">::</span><span class="identifier">dladdr</span></code>
                to show information about the symbol. Requires linking with <span class="bold"><strong>libdl</strong></span> library on POSIX platforms.
              </p>
            </td>
<td>
              <p>
                Any compiler on POSIX or MinGW
              </p>
            </td>
<td>
              <p>
                no
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <span class="bold"><strong>BOOST_STACKTRACE_USE_WINDBG_CACHED</strong></span>
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>boost_stacktrace_windbg_cached</strong></span>
              </p>
            </td>
<td>
              <p>
                Uses COM to show debug info and caches COM instances in TLS for better
                performance. Useful only for cases when traces are gathered very
                often. <a href="#ftn.stacktrace.configuration_and_build.f2" class="footnote" name="stacktrace.configuration_and_build.f2"><sup class="footnote">[c]</sup></a> May require linking with <span class="bold"><strong>ole32</strong></span>
                and <span class="bold"><strong>dbgeng</strong></span>.
              </p>
            </td>
<td>
              <p>
                MSVC, Intel on Windows
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
<td>
              <p>
                no
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <span class="bold"><strong>BOOST_STACKTRACE_USE_BACKTRACE</strong></span>
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>boost_stacktrace_backtrace</strong></span>
              </p>
            </td>
<td>
              <p>
                Requires linking with <span class="bold"><strong>libdl</strong></span> on POSIX
                and <span class="bold"><strong>libbacktrace</strong></span> libraries. <span class="bold"><strong>libbacktrace</strong></span> is probably already installed
                in your system<a href="#ftn.stacktrace.configuration_and_build.f3" class="footnote" name="stacktrace.configuration_and_build.f3"><sup class="footnote">[d]</sup></a>, or built into your compiler.
              </p>
              <p>
                Otherwise (if you are a <span class="bold"><strong>MinGW</strong></span>/<span class="bold"><strong>MinGW-w64</strong></span> user for example) it can be downloaded
                <a href="https://github.com/ianlancetaylor/libbacktrace" target="_top">from
                here</a> or <a href="https://github.com/gcc-mirror/gcc/tree/master/libbacktrace" target="_top">from
                here</a>.
              </p>
            </td>
<td>
              <p>
                Any compiler on POSIX, or MinGW, or MinGW-w64
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <span class="bold"><strong>BOOST_STACKTRACE_USE_ADDR2LINE</strong></span>
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>boost_stacktrace_addr2line</strong></span>
              </p>
            </td>
<td>
              <p>
                Use <span class="bold"><strong>addr2line</strong></span> program to retrieve
                stacktrace. Requires linking with <span class="bold"><strong>libdl</strong></span>
                library and <code class="computeroutput"><span class="special">::</span><span class="identifier">fork</span></code>
                system call. Macro <span class="bold"><strong>BOOST_STACKTRACE_ADDR2LINE_LOCATION</strong></span>
                must be defined to the absolute path to the addr2line executable
                if it is not located in /usr/bin/addr2line.
              </p>
            </td>
<td>
              <p>
                Any compiler on POSIX
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
<td>
              <p>
                yes
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <span class="bold"><strong>BOOST_STACKTRACE_USE_NOOP</strong></span>
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>boost_stacktrace_noop</strong></span>
              </p>
            </td>
<td>
              <p>
                Use this if you wish to disable backtracing. <code class="computeroutput"><span class="identifier">stacktrace</span><span class="special">::</span><span class="identifier">size</span><span class="special">()</span></code> with that macro always returns
                0.
              </p>
            </td>
<td>
              <p>
                All
              </p>
            </td>
<td>
              <p>
                no
              </p>
            </td>
<td>
              <p>
                no
              </p>
            </td>
</tr>
</tbody>
<tbody class="footnotes"><tr><td colspan="6">
<div id="ftn.stacktrace.configuration_and_build.f0" class="footnote"><p><a href="#stacktrace.configuration_and_build.f0" class="para"><sup class="para">[a] </sup></a>
                  This will provide more readable backtraces with <span class="bold"><strong>source
                  code locations</strong></span> if the binary is built with debug information.
                </p></div>
<div id="ftn.stacktrace.configuration_and_build.f1" class="footnote"><p><a href="#stacktrace.configuration_and_build.f1" class="para"><sup class="para">[b] </sup></a>
                  This will provide readable function names in backtrace for functions
                  that are exported by the binary. Compiling with <code class="computeroutput"><span class="special">-</span><span class="identifier">rdynamic</span></code> flag, without <code class="computeroutput"><span class="special">-</span><span class="identifier">fisibility</span><span class="special">=</span><span class="identifier">hidden</span></code>
                  or marking functions as exported produce a better stacktraces.
                </p></div>
<div id="ftn.stacktrace.configuration_and_build.f2" class="footnote"><p><a href="#stacktrace.configuration_and_build.f2" class="para"><sup class="para">[c] </sup></a>
                  This may affect other components of your program that use COM,
                  because this mode calls the <code class="computeroutput"><span class="identifier">CoInitializeEx</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="identifier">COINIT_MULTITHREADED</span><span class="special">)</span></code> on first use and does not call
                  <code class="computeroutput"><span class="special">::</span><span class="identifier">CoUninitialize</span><span class="special">();</span></code> until the current thread is
                  destroyed.
                </p></div>
<div id="ftn.stacktrace.configuration_and_build.f3" class="footnote"><p><a href="#stacktrace.configuration_and_build.f3" class="para"><sup class="para">[d] </sup></a>
                  If you are using Clang with libstdc++ you could get into troubles
                  of including <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">backtrace</span><span class="special">.</span><span class="identifier">h</span><span class="special">&gt;</span></code>,
                  because on some platforms Clang does not search for headers in
                  the GCC's include paths and any attempt to add GCC's include path
                  leads to linker errors. To explicitly specify a path to the <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">backtrace</span><span class="special">.</span><span class="identifier">h</span><span class="special">&gt;</span></code> header you could define the
                  <span class="bold"><strong>BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE</strong></span>
                  to a full path to the header. For example on Ubuntu Xenial use
                  the command line option <span class="bold"><strong>-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=&lt;/usr/lib/gcc/x86_64-linux-gnu/5/include/backtrace.h&gt;</strong></span>
                  while building with Clang.
                </p></div>
</td></tr></tbody>
</table></div>
</div>
<br class="table-break"><p>
      <span class="bold"><strong>Examples:</strong></span>
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          if you wish to switch to more powerful implementation on Clang/MinGW and
          <span class="bold"><strong>BOOST_STACKTRACE_LINK</strong></span> is defined, you
          just need link with "<span class="bold"><strong>-lboost_stacktrace_backtrace
          -ldl -lbacktrace</strong></span>" or "<span class="bold"><strong>-lboost_stacktrace_addr2line
          -ldl</strong></span>"
        </li>
<li class="listitem">
          if you wish to disable backtracing and <span class="bold"><strong>BOOST_STACKTRACE_LINK</strong></span>
          is defined, you just need link with <span class="bold"><strong>-lboost_stacktrace_noop</strong></span>
        </li>
<li class="listitem">
          if you wish to disable backtracing and you use the library in header only
          mode, you just need to define <span class="bold"><strong>BOOST_STACKTRACE_USE_NOOP</strong></span>
          for the whole project and recompile it
        </li>
</ul></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="stacktrace.configuration_and_build.mingw_and_mingw_w64_specific_not"></a><a class="link" href="configuration_and_build.html#stacktrace.configuration_and_build.mingw_and_mingw_w64_specific_not" title="MinGW and MinGW-w64 specific notes">MinGW
      and MinGW-w64 specific notes</a>
</h3></div></div></div>
<p>
        MinGW-w64 and MinGW (without -w64) users have to install libbacktrace for
        getting better stacktraces. Follow the instruction:
      </p>
<p>
        Let's assume that you've installed MinGW into C:\MinGW and downloaded <a href="https://github.com/ianlancetaylor/libbacktrace" target="_top">libbacktrace sources</a>
        into C:\libbacktrace-master
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            Configure &amp; build libbacktrace from console:
            <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
                  C:\MinGW\msys\1.0\bin\sh.exe
                </li>
<li class="listitem">
                  cd /c/libbacktrace-master
                </li>
<li class="listitem">
                  ./configure CC=/c/MinGW/bin/gcc.exe CXX=/c/MinGW/bin/g++.exe
                </li>
<li class="listitem">
                  make
                </li>
<li class="listitem">
                  ./libtool --mode=install /usr/bin/install -c libbacktrace.la '/c/libbacktrace-master'
                </li>
</ul></div>
          </li>
<li class="listitem">
            Add info to the project-config.jam in the Boost folder:
            <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
                  using gcc : 6 : "C:\MinGW\bin\g++.exe" : &lt;compileflags&gt;-I"C:\libbacktrace-master\"
                  &lt;linkflags&gt;-L"C:\libbacktrace-master\" ;
                </li></ul></div>
          </li>
<li class="listitem">
            Now you can use a header only version by defining <span class="bold"><strong>BOOST_STACKTRACE_USE_BACKTRACE</strong></span>
            for your project or build the stacktrace library from Boost folder:
            <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
                  b2.exe toolset=gcc-6 --with-stacktrace
                </li></ul></div>
          </li>
</ul></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2016-2019 Antony
      Polukhin<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="getting_started.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../stacktrace.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>