Why doesn't this work:
#include <regex>
int main() {
return 0;
}
Compiled as:
clang++ -std=c++11 -stdlib=libstdc++ temp.cpp
temp.cpp:1:10: fatal error: 'regex' file not found
#include <regex>
^
1 error generated.
clang++ --version
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
If I allow stdlib
to be libc++
then it compiles. Regex is c++11
, but clang
doesn't seem to have a problem with both -std=c++11 -stdlib=libstdc++
per se. On my machine at least, it looks like there's something I could use in /usr/include/regex.h
, but that's not standard, and besides there are things other than regex I'd like to use (e.g. std::to_string).
The reason this has come up is because I'd like to link to a 3rd party library (for which I don't have the source) which is complied as std::string
and not std::__1::basic_string
, but my code uses std::regex
and std::to_string
. I'm not sure I want to introduce a dependency on boost.
Libstdc++ is the standard C++ library. It is needed to compile C++ code (part of GCC is written in C++), but we had to defer its installation when we built gcc-pass1 because it depends on glibc, which was not yet available in /tools. Approximate build time: 0.5 SBU. Required disk space: 878 MB.
This happens even when the libstdc++ is installed and the file is available in /usr/local/lib/libstdc++.so. By default, the ds_agent looks for the required library in the /opt/ds_agent/lib folder.
Libsupc++ is a support library for g++ that contains functions dealing with run-time type information (RTTI) and exception handling. If you attempt to use either exceptions or RTTI in a C++ kernel you have compiled with a GCC Cross-Compiler you will also need the libsupc++ library.
GCC libstdc++ has been backward compatible with no ABI breaks for around a decade. GNU libc for what, two decades. You don't break such fundamental ABIs on a whim. If the libstdc++ ABI had changed, it would have broken every single bit of C++ code built with GCC4 over the last decade.
Apple ships a very old version of libstdc++ with OS X (4.2.1 I think). That version did not fully support C++11, so you'll need to get a newer version to use std::regex
.
The version of libstdc++ shipped with OS X comes from gcc-4.2.1, the last version of GCC before FSF decided to adopt GPL3. Apple deprecated libstdc++ in OS X Lion in favor of libc++ from the LLVM Project. If you want to use C++11 on OS X, you should be using -std=c++11 -stdlib=libc++
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With