Error: no type named "shared_ptr" in namespace std

I included the <memory> header in my program, and tried to use std::shared_ptr and I get an error that no such type exists, from Clang with -std=c++11 active. GCC gives similar errors. Here's my code:

1
2
3
4
5
6
7
#include <memory>

int main(int argc, char* args[]) {
	std::shared_ptr<int> somePtr;

	return 0;
};


Clang -v output:
1
2
3
clang version 3.5 (trunk 197674)
Target: x86_64-apple-darwin11.4.2
Thread model: posix


And also, for the other version of Clang I used (from XCode command line tools):
1
2
3
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix


What's happening? I can even go into the include headers and see where it has, on line 460 of boost_shared_ptr (which gets included when I #include <memory>), a declaration of shared_ptr. Why isn't the compiler recognizing shared_ptr?
Compile with `-std=c++11' flag
Already did, but still no luck.
Compile with -stdlib=libc++.
(Ask clang to use its own standard library instead of an old GNU standard library)

For instance:
> clang++ -std=c++11 -stdlib=libc++ -Wall -Wextra -pedantic-errors my_program.cc
What about std::tr1::shared_ptr?
EDIT* I'm stupid
Last edited on
Compile with -stdlib=libc++.


Worked!
Topic archived. No new replies allowed.