Introduction
Installation on Mac OS X follows the general steps outlined in Installing ODB on Linux/UNIX. This guide presents additional information for this platform and should be read first.
Prerequisites
The ODB compiler binary package requires Command Line Tools. Even
if you are planning to use another C++ compiler (e.g., from XCode
or Qt Creator), you still need to install this package in order
to have system headers in /usr/include
.
To install Command Line Tools, run:
xcode-select --install
Installing the ODB Compiler
It is highly recommended that you use the "official" binary package provided. There are Homebrew formulas around that you may use. If you choose to do so, it is even more highly recommended that you only use them for the ODB compiler, and not the runtimes (see below).
Installing the Runtime Libraries
Mac OS X now includes two versions of the standard C++ library:
GCC's libstdc++
and Clang's libc++
.
It is extremely important that you use the same one
for ODB runtimes and your application. If you do not and you
are lucky, then you will get link-time unresolved symbol errors.
If you are unlucky, then you will get runtime crashes and only in
certain situations (e.g., when your application throws an
exception).
As a general rule, it is recommended that you use exactly the
same compiler and exactly the same options to build the ODB
runtimes as you build your application. Before integrating
ODB into your project, build it and notice the command line
used to compile your C++ source code (if you use an IDE, you
might have to dig around for build logs). Use the same C++
compiler path/name to build the ODB runtimes. The options that
you need to pay special attention to are --std
(C++
standard), -m32/-m64 (architecture), and --stdlib
(C++ standard library). Make sure that if any of them are
specified when building your application that they are also
specified when configuring the ODB runtimes.
Because of the possibility of the runtime mismatches, it is always
a good idea to run otool -L
on your application's
executable. If you see both libstdc++
and
libc++
, then you have a problem. To find the culprit,
run otool -L
on each of the libraries that your
application links.