Reputation: 6507
When compiling this file
#include <vector>
int main(int argc, char* argv[])
{
std::vector<int> IntVector;
}
using the version of clang shipping with Xcode, I can tell clang to use llvm's libc++ like this:
$ clang -std=c++11 -stdlib=libc++ t.cpp -lc++ -o t
When using a self-built version of clang, however, this command does not work because clang cannot find libc++:
$ /my/clang -std=gnu++11 -stdlib=libc++ t.cpp -lc++ -o t
t.cpp:1:10: fatal error: 'vector' file not found
#include <vector>
^
1 error generated.
I know that I can download, build and install libc++ from sources; however, I'd much rather use the version shipping with Xcode.
How can I use the libc++ version shipping with Xcode when using my own version of clang?
Upvotes: 0
Views: 1056
Reputation: 218700
First determine where libc++ is: It will be located within the Xcode app itself. If you have trouble finding it, preprocess a HelloWorld using Xcode and inspect it for the path to a std header.
Then on your command line point to the include
directory with -I
. You can also use -nostdinc++
to guarantee that no other std headers will be looked for:
$ /my/clang -std=gnu++11 -stdlib=libc++ t.cpp -nostdinc++ -I<path-to-libcxx>/include
Upvotes: 2