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> </ul>
<p> <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 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 (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 10.7 will not boot without a valid copy of <code>libc++.1.dylib</code> in
<code>/usr/lib</code>. <code>/usr/lib</code>.
</p> </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> <p>
Next: Next:
</p> </p>
@ -160,25 +153,18 @@
<ul> <ul>
<li><code>cd libcxx/lib</code></li> <li><code>cd libcxx/lib</code></li>
<li><code>export TRIPLE=-apple-</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>./buildit</code></li>
<li><code>ln -sf libc++.1.dylib libc++.dylib</code></li>
</ul> </ul>
<p> <p>
That should result in a libc++.1.dylib. To install it I like to use links That should result in a libc++.1.dylib and libc++.dylib. The safest thing
instead of copying, but either should work: to do is to use it from where your libcxx is installed instead of replacing
these in your Mac OS.
</p> </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> <p>
To use with clang you can: To use your system-installed libc++ with clang you can:
</p> </p>
<ul> <ul>
@ -186,20 +172,25 @@
<li><code>clang++ -std=c++11 -stdlib=libc++ test.cpp</code></li> <li><code>clang++ -std=c++11 -stdlib=libc++ test.cpp</code></li>
</ul> </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> <p>To run the libc++ test suite (recommended):</p>
<ul> <ul>
<li><code>cd libcxx/test</code></li> <li><code>cd libcxx/test</code></li>
<li><code>./testit</code></li> <li><code>./testit</code></li>
<ul> <ul>
<li>On Mac OS 10.6, to work around bugs in libc headers like <li>You can alter the command line options <code>testit</code> uses
math.h and inttypes.h, add "-U__STRICT_ANSI__" and with <code>export OPTIONS="whatever you need"</code></li>
"-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>
</ul> </ul>
</ul> </ul>