New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use -stdlib=libc++ on macOS #1361
Conversation
Nice fix! I have a similar problem on OSX when I built SFML using Clang and CMake in QtCreator. I got linker errors when using the so compiled SFML in a project which uses the same setup. The linker errors point to a mismatch in standart library versions. I was not able to find the root of the mismatch, but compiling SFML with |
Thanks! We can keep CMAKE_OSX_DEPLOYMENT_TARGET to 10.7 for now I think but at some point we'll indeed drop support for older releases of macOS. Just a quick question about this PR: I've noticed a specific Xcode attribute. Is it absolutely necessary? Are there others such settings we should/could be using? |
I just gave this a test and can confirm that it indeed fixes the linker issues I had. 👍 |
@mantognini For the Xcode attribute, it is not mandatory but is just for better integration in Xcode. With the Xcode attribute, in build settings for the standard library entry it will show libc++. If you set the CMAKE_CXX_FLAGS with Xcode generator, in build settings the standard library entry will just remain « Default for compiler » and you’ll have -stdlib=libc++ in « Other C++ flags ». And no I don’t know about other attributes to set right now. Also it’s usually a better idea to set a compilation flag rather than an Xcode attribute so that it works with any generator. (NB: I rebased on master so you should relaunch CI builds) @Foaly Nice that it solved your problems too :) Working with Xcode for another PR I got bored to manually change that setting after each CMake generation. |
79c3797
to
92e0b69
Compare
Alright, looks good to me! |
I ran into this problem again today and it cost me about half an hour before I figured out it was this again... |
Merged in 511c163 |
@mantognini @Ceylo This is wrong to hardcode runtime library and it breaks builds with GCC. A correct fix would be to use Clang library only with Clang, obviously. |
GCC fails for other reasons on macOS currently. If you find out how to fix the generated errors, then we're more than happy to merge a fix. |
@eXpl0it3r ObjC garbage fails, I suspect. I am not sure Cocoa will be fixable on my system (it should be possible to rewrite it in normal C/C++, but I can’t), but it should work on a modern macOS. Can you refer to the issue, what fails with GCC build? |
@eXpl0it3r Thank you. I think I saw that sign conversion error referred to in #2582 |
FYI, this breaks with clang too:
Note that it breaks late in the build process. Also: I don't like |
That warning has already been fixed |
Confirm. Clang build succeeds cleanly with latest git pull. |
Duplicates #2790 |
Forum thread
https://en.sfml-dev.org/forums/index.php?topic=22786.msg159283#msg159283
Rationale
The standard library "stdc++" causes warnings when linking on macOS:
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
Build logs in SFML CI show this too. Also current downloads for macOS are built with libc++, so the CI doesn't build with what's currently shipped.
Regarding any possible compatibility issue, note that libc++ is available since macOS 10.7.
@mantognini Should CMAKE_OSX_DEPLOYMENT_TARGET also be changed from 10.7 to 10.9 as suggested by the deprecation warning?