Does OS X 10.7 libc++ support c++14? - c++

I'm updating a project to use the latest Qt and taking the opportunity to switch to libc++ and C++11 at the same time. My understanding is that OS X 10.7 and above support this without me needing to ship my own build of the standard library. I'm happy to no longer support OS X versions <10.7.
C++11 support is great, but I'd really like to use C++14.
Does the libc++ installed for end-users with OS X >10.7 also support C++14 standard library features?
My guess is 'Yes' and that it's kept up to date by OS updates in >10.7 - but I've been unable to find a definitive source stating this to be the case.

Probably not. Apple shipped the last update for Mac OS X 10.7 (10.7.5) in October 2012; it's unlikely that the libc++.dylib has been updated since then (the only exception that I could think of is for security issues)
Xcode ships with a set of headers that change with what SDK you target; if you target a particular system (say 10.7), you get those headers.
Compare the contents of /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/ and /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/ too see what I mean.
For template-only features, you could use your own set of headers from a later LLVM release - but then you would be taking the burden of ensuring compatibility upon yourself.

Related

Link errors with AutoSeededRandomPool when using Xcode and libc++

Trying to develop simple c++ stuff in xcode for the first time. I haven't done c++ for a while, nor do I usually use a mac so bear with me if this is trivial.
I have simply grabbed the AutoSeededRandomPool example source from here: http://www.cryptopp.com/wiki/RandomNumberGenerator#AutoSeededRandomPool
I used macports to grab libcryptopp +universal (the non universal one didnt work either though), and I have added libcryptopp.a to the 'link binaries with libraries' build phase for my target.
During the build I get 22 errors, which you can see for yourself here: http://i.imgur.com/wIhEQot.jpg
Using xcode 4.6.2 on oldish Lion OS X macbook pro.
Have I missed something obvious here? Thanks for your help
You're not using the correct compiler — The project you mention states the requirement is:
Xcode 3.2.5,
Xcode 4.0 and GCC 4.2,
targeting Apple iOS
...It appears you're using clang++
http://www.cryptopp.com/#platforms
Also this says iOS, not OS X - That could certainly cause some issues as well. Why bother messing with this crypto library anyway? Use Apple's or one that was meant specifically to be used with OS X. It's of course your choice, but it certainly doesn't make it any easier going this route.
I have found the source of the problem was linking with the libc++ standard library rather than the more standard libstdc++ library. Xcode and Mac OS X targets were not a problem.
If I link against libstdc++ then the linking errors disappear. For future reference the giveaway seems to be the std::__1 namespacing visible in the errors, although with hindsight perhaps it should have been obvious that a library ported from linux would most likely be using the libstdc++ library.

Binary compatibility (using C++11) on older distro versions

I am using GCC to compile a C++ application on Ubuntu 13. I want to be able to use C++11 features in my code, but at the same time still be able to produce a binary that my users can run on older versions of Ubuntu.
If I compile on Ubuntu 13 with the latest version of GCC my binary will not run on Ubuntu 12 since glibc is not forward compatible:
(How compatible are different versions of glibc?)
What are my options?
Is this even possible without requiring my users to jump through massive hoops?
If not, what do my users have to do to be able to run the binary (i.e. can they install the newer glibc on the older version of Ubuntu)?
Note: I don't not want to consider statically linking glibc since:
I've read that this is a very bad idea
Licensing issues
Cross-distribution compatibility issues
Currently my application does not use any C++11 features and I compile on an older version of Ubuntu with an older version of GCC to avoid this problem. But it makes me sad not being able to use the latest and greatest language features :(
You can try to use Boost Libraries which have quite the same features as C++11 and is "more retro-compatible" than C++11 : it will easily compile on older version of Ubuntu.
Otherwise the best option might be to ask to the users of Ubuntu 12.04 to upgrade there GCC from 4.6 to 4.7 or more recent :
http://www.swiftsoftwaregroup.com/upgrade-gcc-4-7-ubuntu-12-04/
You are asking "how do I use code that isn't on older systems".
The answer is of course, "Include the code with your project".
If you think through what you're asking, you'll realize that in any case, you'll need the code for the c++11 functions in libstdc++. So if they aren't on ubuntu 12, YOU have to add them. Therefore, you'd have to have it statically linked. it's the only way to ensure it will run on an arbitrary ubuntu12 system.
Well you could make a fancy installation, but in the end, it'd just be your apps "dynamically linking" to the libstdc++, so it may as well be statically linked, since no other program is going to be looking for it on ubuntu12
In general, a c++ library is compatible only if the same compiler is used and (!) the versions of the compilers are matching (you might be lucky, though). There is no way to be portable in this sense, besides writing C-code.

Requiring OS X >= Lion for an application

One of the open source software I'm contributing to has recently started using features that are only available on OS X 10.7 and later. We'd like to detect at startup time (or preferably before the program is even started, if some DMG metadata allows for that) if a user is using an older version of OS X and display a message telling him to upgrade his OS (or use an older version of our software).
What is the best way to do this? I'm not an OS X developer so please keep it as simple as possible :)
You can do it using methods in the C std library. This question explains how Getting the OS version in Mac OS X using standard C
As mentioned in the comments this was deprecated in 10.8. This question explains a work around for the time being How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?

C++11 with Xcode on Mac OS X Snow Leopard

I have project that is at times developed on Windows/Visual Studio 2010 and uses some C++11 features and I need to be able to develop/build on Mac OS X. When I tried to build the project with Xcode I got a lot of errors around new C++11 features and checked the gcc version to find it's pretty old (4.2).
It looks like Apple is trying to force developers to pay an unnecessary upgrade to Lion by refusing to allow Xcode 4+ to be downloaded on any other version of Mac OS thus I'm left with Xcode 3.x.
How can I continue to use C++11 on Snow Leopard? Is there a way I can do this and keep Xcode as an IDE?
Update feb.25 2012: There are now a lot of features available for you to work with using the latest clang. Maybe you could target 10.6 if you use language features only. If you need library features, you will need 10.7.
given the present (sept.24.2011) state of the Xcode toolset, it's easiest (IMO) to choose another ide or os if you need c++11 support.
the fork of gcc xcode uses will never support these features. clang is pretty far behind wrt c++11 features (because its c++ implementation is still very new and other compilers have had a few extra years). therefore, the compilers xcode ships with do not presently support enough features for c++11 development, regardless of the version of osx you use.
you can install a newer version of gcc and use another ide fairly easily.
technically, you can also make a plugin for xcode 3 (not officially supported) which invokes another compiler (e.g. a more recent release of gcc). that route has been closed in xc4 (afaik). Update apparently, it's still available in Xc4; see idljarn's comment below.
for many projects, it's easier to just use your mac to boot into linux or windows (or use virtualization).
your final option is intel's compiler, which can be used in xcode and provides a decent amount of c++11 support -- try it with xcode before you buy to see if it fits your needs, plays well with xcode, and supports the c++11 features your team uses.
lastly, i don't think they do this for your upgrade money. they really don't maintain xcode for multiple releases very well - they just expect you to stay with the latest and greatest unless you need backwards compatibility; you just stop upgrading in that case. they invested in and assisted development of clang after gcc's license changed. so yeah... osx has always been very far behind wrt c++11 support because they decided to switch to another (very young) compiler. if you wait for xcode to support c++11, you will have to wait for clang to support it, which can be quite some time.
I just saw this now and I would like to update you on this. LLVM currently shipping with XCode is at version 3 (Source). This current version is very good with supporting C++11. Here is a link to what is supported:
http://clang.llvm.org/cxx_status.html
You can compare this with the current GCC support here:
http://gcc.gnu.org/projects/cxx0x.html
As you can see, Clang is currently not far behind, if it is at all, with features of the new standard being supported. The only thing that I see concerning is the lack of support for concurrency features, but that is the case for most C++11 compilers due to the nature of supporting it.So I hope that this answer is not too late and that you are not deterred. Go get the latest version of Xcode and fire away (If you have not done so already ;) )!

gcc version 4.1.2 in mac os x

I am taking a programming class and we are required to use the gcc 4.1.2 compiler to compile our c++ projects. I will be creating my projects in xcode and can't find how to set that compiler. I went to the get info window on the project and hit the drop down under Compiler Version, however I do not have 4.1.2 on the list. It seems that this compiler is not installed on my computer. Does anybody know where I can download it and how I can set it as my system default gcc compiler for the term?
You can probably get away with using whatever version of GCC is on your Mac, and doing a final compile on the university machines as a check. In general, the user visible changes using a later version is stricter syntax checking, so you might do something on the Mac that won't pass a newer compiler, but that generally isn't too common. I haven't had to change more than a few lines on our 50k line codebase.
With the current developer tools, only gcc 4.0 and 4.2 are available. You could probably get gcc 4.1.2 via MacPorts, however, I'm not sure whether you can integrate it into XCode.
Before you try this, you should maybe first check with the class instructor whether it is really necessary to use exactly 4.1.2, or if it is OK to use 4.0 resp. 4.2 instead.