Update instructions for building and using libc++ on Mac OS

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@167490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2012-11-06 21:31:37 +00:00
parent ff9267709d
commit 22b781bf0c

View File

@ -139,20 +139,13 @@
</ul>
<p>
On Mac OS 10.7 (Lion), the easiest way to get this library is to install
On Mac OS 10.7 (Lion) and later, the easiest way to get this library is to install
Xcode 4.2 or later. However if you want to install tip-of-trunk from here
(getting the bleeding edge), read on. However, be warned that Mac OS
10.7 will not boot without a valid copy of <code>libc++.1.dylib</code> in
<code>/usr/lib</code>.
</p>
<p>To build on Mac OS X 10.6 (Snow Leopard), you need a helper library and header
<a href="http://home.roadrunner.com/~hinnant/libcppabi.zip">found here</a>.
cp cxxabi.h to /usr/include, and cp libc++abi.dylib to /usr/lib. On Mac OS
X 10.7 (Lion) and later, this helper library and header are already installed
for you.
<p>
<p>
Next:
</p>
@ -160,25 +153,18 @@
<ul>
<li><code>cd libcxx/lib</code></li>
<li><code>export TRIPLE=-apple-</code></li>
<li>Only on 10.6: <code>export MACOSX_DEPLOYMENT_TARGET=10.6</code></li>
<li><code>./buildit</code></li>
<li><code>ln -sf libc++.1.dylib libc++.dylib</code></li>
</ul>
<p>
That should result in a libc++.1.dylib. To install it I like to use links
instead of copying, but either should work:
That should result in a libc++.1.dylib and libc++.dylib. The safest thing
to do is to use it from where your libcxx is installed instead of replacing
these in your Mac OS.
</p>
<ul>
<li><code>cd /usr/lib</code></li>
<li><code>sudo ln -sf path-to-libcxx/lib/libc++.1.dylib libc++.1.dylib</code></li>
<li><code>sudo ln -sf libc++.1.dylib libc++.dylib</code></li>
<li><code>cd /usr/include/c++</code></li>
<li><code>sudo ln -sf path-to-libcxx/include v1</code></li>
</ul>
<p>
To use with clang you can:
To use your system-installed libc++ with clang you can:
</p>
<ul>
@ -186,20 +172,25 @@
<li><code>clang++ -std=c++11 -stdlib=libc++ test.cpp</code></li>
</ul>
<p>
To use your tip-of-trunk libc++ on Mac OS with clang you can:
</p>
<ul>
<li><code>export DYLD_LIBRARY_PATH=&lt;path-to-libcxx&gt;/lib</code>
<li><code>clang++ -std=c++11 -stdlib=libc++ -nostdinc++
-I&lt;path-to-libcxx&gt;/include -L&lt;path-to-libcxx&gt;/lib
test.cpp</code></li>
</ul>
<p>To run the libc++ test suite (recommended):</p>
<ul>
<li><code>cd libcxx/test</code></li>
<li><code>./testit</code></li>
<ul>
<li>On Mac OS 10.6, to work around bugs in libc headers like
math.h and inttypes.h, add "-U__STRICT_ANSI__" and
"-D__STDC_FORMAT_MACROS" to the command line with:
<blockquote>
<pre>export OPTIONS="-std=c++11 -stdlib=libc++ -U__STRICT_ANSI__ -D__STDC_FORMAT_MACROS"</pre>
</blockquote></li>
<li>People porting libc++ to other OSes will likely have to
define similar macros.</li>
<li>You can alter the command line options <code>testit</code> uses
with <code>export OPTIONS="whatever you need"</code></li>
</ul>
</ul>