libc++

Where does the __1 symbol come from when using LLVM's libc++?

左心房为你撑大大i 提交于 2019-11-27 14:48:48
I see a fair amount of questions like Apple Mach-O Linker (Id) Error and Undefined symbols in cryptopp at IOS 64-bit project . The problem is usually described as: Undefined symbols for architecture i386: "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from: cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o) The problem often reduces to mixing/matching -stdlib=libc++ (LLVM C++ runtime) and -stdlib=libstdc++ (GNU C++ runtime). The LLVM C++ runtime ( libc++ ) has an __1 decoration symbol, but the GNU C++ runtime libstdc++ lacks the

Compiling with Clang using Libc++ undefined references

只愿长相守 提交于 2019-11-27 13:33:13
问题 The first couple are too long to reference. I get this error when I try to compile clang++ -stdlib=libc++ ../main.cc ... with clang and libc++ from the SVN. error: undefined reference to 'typeinfo for char const*' error: undefined reference to '__cxa_allocate_exception' error: undefined reference to '__cxa_throw' /tmp/cc-pbn00y.o:../main.cc:function std::__1::deque<double, std::__1::allocator<double> >::__add_back_capacity(): error: undefined reference to '__cxa_begin_catch' /tmp/cc-pbn00y.o:

Using libstdc++ compiled libraries with clang++ -stdlib=libc++

本秂侑毒 提交于 2019-11-27 10:27:16
I am working in C++ under Mac OS X (10.8.2) and I recently came up with the need of using C++11 features, which are available through the clang++ compiler using the libc++ stdlib. However, I also need to use some legacy library compiled and linked against libstdc++ (coming from MacPorts). In doing so, I got linking errors, since the headers of the legacy libraries using, e.g., std::string , required to be resolved against the std::__1::basic_string (i.e., the libc++ implementation of std::string ) instead of the std::basic_string implementation. Is there a way to mix the two libraries in

std::istream operator exception reset / not thrown

喜欢而已 提交于 2019-11-27 08:05:52
问题 I'm not sure about how to use std::istream::exception according to the standard , to let std::istream::operator>> throw an exception if it can't read the input into a variable, e.g. double. The following code has different behavior with clang/libc++ and gcc/libstdc++: #include <iostream> #include <cassert> int main () { double foo,bar; std::istream& is = std::cin; is.exceptions(std::istream::failbit); is >> foo; //throws exception as expected with gcc/libstdc++ with input "ASD" std::cout <<

What Effect Would LWG2349 Have?

喜夏-厌秋 提交于 2019-11-27 07:45:15
问题 While libstdc++ does not, libc++ does follow the standard which states that passing ios_base::failbit to basic_istream::exceptions has no effect on formatted input. For example this code: istringstream is{"ASD"}; double foo; is.exceptions(istream::failbit); try { is >> foo; cout << foo << endl; } catch(ios_base::failure& fail) { cout << "ouch\n"; } Would result in: "ouch" on libstdc++ "0" on libc++ My reading of LWG2349 is that it would cause basic_istream to not throw on any formatted input.

Why does libc++'s implementation of std::string take up 3x memory as libstdc++?

雨燕双飞 提交于 2019-11-27 04:25:42
Consider the following test program: #include <iostream> #include <string> #include <vector> int main() { std::cout << sizeof(std::string("hi")) << " "; std::string a[10]; std::cout << sizeof(a) << " "; std::vector<std::string> v(10); std::cout << sizeof(v) + sizeof(std::string) * v.capacity() << "\n"; } Output for libstdc++ and libc++ respectively are: 8 80 104 24 240 264 As you can see, libc++ takes 3 times as much memory for a simple program. How does the implementation differ that causes this memory disparity? Do I need to be concerned and how do I workaround it? Here is a short program to

Is make_shared really more efficient than new?

走远了吗. 提交于 2019-11-27 04:12:56
问题 I was experimenting with shared_ptr and make_shared from C++11 and programmed a little toy example to see what is actually happening when calling make_shared . As infrastructure I was using llvm/clang 3.0 along with the llvm std c++ library within XCode4. class Object { public: Object(const string& str) { cout << "Constructor " << str << endl; } Object() { cout << "Default constructor" << endl; } ~Object() { cout << "Destructor" << endl; } Object(const Object& rhs) { cout << "Copy constructor

Why the libc++ std::vector internally keeps three pointers instead of one pointer and two sizes?

做~自己de王妃 提交于 2019-11-27 03:11:50
问题 I'm looking at the implementation of std::vector in libc++ and I noticed that it internally keeps three pointers (one to the begin, one the end, and one to the end of the allocated memory) instead of what I'd instinctively do, i.e., one pointer to the begin and two size and capacity members. Here is the code from libc++'s <vector> (ignore the compressed pair, I know what it means). pointer __begin_; pointer __end_; __compressed_pair<pointer, allocator_type> __end_cap_; I noticed that also

How to Build libcxx and libcxxabi by clang on CentOS 7

别说谁变了你拦得住时间么 提交于 2019-11-27 00:38:33
问题 I want to use C++11 or C++14 with clang/clang++ on CentOS 7. How do I build this building environment? 回答1: This article teaches how to build C++11 building environment on CentOS 7: RHEL's EPEL repo provides Clang packages, but no C++ library packages. So, these parts are a bit troublesome to be built by hand. The customized C++ libraries for Clang is libc++ (libcxx) [1]. Then, libcxx also needs an ABI library, libc++abi (libcxxabi) [2]. Unfortunately, these two libraries have a circular

How to compile/link Boost with clang++/libc++?

大城市里の小女人 提交于 2019-11-26 18:26:57
The answer to this question Why can't clang with libc++ in c++0x mode link this boost::program_options example? states "You need to rebuild boost using clang++ -stdlib=libc++." I'm using MacOS Lion with clang v3.0. How do I build Boost v1.48.0 using clang and link it with libc++? Update: I've created a user-config.jam file with the following: using clang-darwin ...which will build Boost with clang instead of gcc. How do I link with libc++ instead of libstdc++? Howard Hinnant I didn't know how to do this either. But after poking around in here , the getting started , and trial and error: $ .