Why is the c++ standard library not working?

前端 未结 1 1136
情话喂你
情话喂你 2021-01-14 04:35

I\'ve been trying to get my program that I downloaded from my schools server to run offline on my mac. I tried updating GCC by following tutorials and for some reason the tu

相关标签:
1条回答
  • 2021-01-14 04:38

    Apple's gcc is really outdated. Try to build using clang and libc++ instead of gcc and libstdc++. Compile flags: -std=c++11 -stdlib=libc++, link flag: -stdlib=libc++. Use clang++ instead of g++.

    Edit: note that you need to install latest command line tools for this to work.
    Open XCode. Go to "Xcode" -> "Preferences..." -> "Downloads" tab. Select "Command Line Tools" and install them. If it says that it is installed - check for updates by clicking on "Check and Install Now" button.
    After that type clang++ --version in terminal and you should see something like next:

    Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
    Target: x86_64-apple-darwin12.3.0
    Thread model: posix
    

    Edit 2: if that didn't help and you still have an outdated version of compiler. Try to use xcrun clang++ instead of clang++ in your makefile. That will use xcode toolchain.

    0 讨论(0)
提交回复
热议问题