Skip to content

Commit c9dc51a

Browse files
committed
Move FAQ and add entry on standard library symbol linker errors on macos, related to #216
1 parent e6d55b5 commit c9dc51a

File tree

1 file changed

+49
-30
lines changed

1 file changed

+49
-30
lines changed

README.md

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ Cpptrace also has a C API, docs [here](docs/c-api.md).
1616

1717
- [30-Second Overview](#30-second-overview)
1818
- [CMake FetchContent Usage](#cmake-fetchcontent-usage)
19-
- [FAQ](#faq)
20-
- [What about C++23 `<stacktrace>`?](#what-about-c23-stacktrace)
21-
- [What does cpptrace have over other C++ stacktrace libraries?](#what-does-cpptrace-have-over-other-c-stacktrace-libraries)
2219
- [Prerequisites](#prerequisites)
2320
- [Basic Usage](#basic-usage)
2421
- [`namespace cpptrace`](#namespace-cpptrace)
@@ -57,6 +54,10 @@ Cpptrace also has a C API, docs [here](docs/c-api.md).
5754
- [Summary of Library Configurations](#summary-of-library-configurations)
5855
- [Testing Methodology](#testing-methodology)
5956
- [Notes About the Library](#notes-about-the-library)
57+
- [FAQ](#faq)
58+
- [What about C++23 `<stacktrace>`?](#what-about-c23-stacktrace)
59+
- [What does cpptrace have over other C++ stacktrace libraries?](#what-does-cpptrace-have-over-other-c-stacktrace-libraries)
60+
- [I'm getting undefined standard library symbols like `std::__1::basic_string` on MacOS](#im-getting-undefined-standard-library-symbols-like-std__1basic_string-on-macos)
6061
- [Contributing](#contributing)
6162
- [License](#license)
6263

@@ -163,33 +164,6 @@ On macOS it is recommended to generate a `.dSYM` file, see [Platform Logistics](
163164
For other ways to use the library, such as through package managers, a system-wide installation, or on a platform
164165
without internet access see [How to Include The Library](#how-to-include-the-library) below.
165166

166-
# FAQ
167-
168-
## What about C++23 `<stacktrace>`?
169-
170-
Some day C++23's `<stacktrace>` will be ubiquitous. And maybe one day the msvc implementation will be acceptable.
171-
The original motivation for cpptrace was to support projects using older C++ standards and as the library has grown its
172-
functionality has extended beyond the standard library's implementation.
173-
174-
Cpptrace provides functionality beyond what the standard library provides and what implementations provide, such as:
175-
- Walking inlined function calls
176-
- Providing a lightweight interface for "raw traces"
177-
- Resolving function parameter types
178-
- Providing traced exception objects
179-
- Providing an API for signal-safe stacktrace generation
180-
- Providing a way to retrieve stack traces from arbitrary exceptions, not just special cpptrace traced exception
181-
objects. This is a feature coming to C++26, but cpptrace provides a solution for C++11.
182-
183-
## What does cpptrace have over other C++ stacktrace libraries?
184-
185-
Other C++ stacktrace libraries, such as boost stacktrace and backward-cpp, fall short when it comes to portability and
186-
ease of use. In testing, I found neither to provide adaquate coverage of various environments. Even when they can be
187-
made to work in an environment they require manual configuration from the end-user, possibly requiring manual
188-
installation of third-party dependencies. This is a highly undesirable burden to impose on users, especially when it is
189-
for a software package which just provides diagnostics as opposed to core functionality. Additionally, cpptrace provides
190-
support for resolving inlined calls by default for DWARF symbols (boost does not do this, backward-cpp can do this but
191-
only for some back-ends), better support for resolving full function signatures, and nicer API, among other features.
192-
193167
# Prerequisites
194168

195169
> [!IMPORTANT]
@@ -1320,6 +1294,51 @@ A couple things I'd like to improve in the future:
13201294
in dbghelp the library cannot accurately show const and volatile qualifiers or rvalue references (these appear as
13211295
pointers).
13221296

1297+
# FAQ
1298+
1299+
## What about C++23 `<stacktrace>`?
1300+
1301+
Some day C++23's `<stacktrace>` will be ubiquitous. And maybe one day the msvc implementation will be acceptable.
1302+
The original motivation for cpptrace was to support projects using older C++ standards and as the library has grown its
1303+
functionality has extended beyond the standard library's implementation.
1304+
1305+
Cpptrace provides functionality beyond what the standard library provides and what implementations provide, such as:
1306+
- Walking inlined function calls
1307+
- Providing a lightweight interface for "raw traces"
1308+
- Resolving function parameter types
1309+
- Providing traced exception objects
1310+
- Providing an API for signal-safe stacktrace generation
1311+
- Providing a way to retrieve stack traces from arbitrary exceptions, not just special cpptrace traced exception
1312+
objects. This is a feature coming to C++26, but cpptrace provides a solution for C++11.
1313+
1314+
## What does cpptrace have over other C++ stacktrace libraries?
1315+
1316+
Other C++ stacktrace libraries, such as boost stacktrace and backward-cpp, fall short when it comes to portability and
1317+
ease of use. In testing, I found neither to provide adaquate coverage of various environments. Even when they can be
1318+
made to work in an environment they require manual configuration from the end-user, possibly requiring manual
1319+
installation of third-party dependencies. This is a highly undesirable burden to impose on users, especially when it is
1320+
for a software package which just provides diagnostics as opposed to core functionality. Additionally, cpptrace provides
1321+
support for resolving inlined calls by default for DWARF symbols (boost does not do this, backward-cpp can do this but
1322+
only for some back-ends), better support for resolving full function signatures, and nicer API, among other features.
1323+
1324+
## I'm getting undefined standard library symbols like `std::__1::basic_string` on MacOS
1325+
1326+
If you see a linker error along the lines of the following on MacOS then it's highly likely you are mixing standard
1327+
library ABIs.
1328+
1329+
```
1330+
Undefined symbols for architecture arm64:
1331+
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find(char, unsigned long) const", referenced from:
1332+
cpptrace::detail::demangle(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) in libcpptrace.a(demangle_with_cxxabi.cpp.o)
1333+
cpptrace::detail::snippet_manager::build_line_table() in libcpptrace.a(snippet.cpp.o)
1334+
```
1335+
1336+
This can happen when using apple clang to compile cpptrace and gcc to compile your code, or vice versa. The reason is
1337+
that apple clang defaults to libc++ and gcc defaults to libstdc++ and these two standard library implementations are not
1338+
ABI-compatible. To resolve this, ensure you are compiling both cpptrace and your code with the same standard library by
1339+
either using the same compiler for both or using `-stdlib=libc++`/`-stdlib=libstdc++` to control which standard library
1340+
is used.
1341+
13231342
# Contributing
13241343

13251344
I'm grateful for the help I've received with this library and I welcome contributions! For information on contributing

0 commit comments

Comments
 (0)