1

I have a CMake project using SFML which was working fine but after updating to Xcode 10, all of the compiler files that CMake looks for can't be found.

clang: warning: libstdc++ is deprecated; move to libc++

I'm not sure how to move to the different lib source.

I've tried using set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=libc++") to use the flag.

It also tells me: Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- broken. I can run the g++/c++ commands fine in the terminal. I assume they are being looked for in the same spot.

CMake file I'm trying to compile with. Its the SFML one: SFML CMake

Full Error Message:

-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++                                                                               
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- broken

CMake Error at /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeTestCXXCompiler.cmake:44 (message):                                                                                            
  The C++ compiler                                                                                                                                                                                          
  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"                                                                                                              
  is not able to compile a simple test program.                                                                                                                                                             

  It fails with the following output:                                                                                                                                                                       

   Change Dir: /Users/DSchana/Documents/Libraries/SFML/build/CMakeFiles/CMakeTmp



Run Build Command:"/usr/bin/make" "cmTC_af3d5/fast"

  /Applications/Xcode.app/Contents/Developer/usr/bin/make -f
  CMakeFiles/cmTC_af3d5.dir/build.make CMakeFiles/cmTC_af3d5.dir/build

  Building CXX object CMakeFiles/cmTC_af3d5.dir/testCXXCompiler.cxx.o


  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  -arch x86_64 -isysroot
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.07.sdk
  -mmacosx-version-min=10.7 -o
  CMakeFiles/cmTC_af3d5.dir/testCXXCompiler.cxx.o -c
  /Users/DSchana/Documents/Libraries/SFML/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx


  warning: include path for stdlibc++ headers not found; pass '-std=libc++'
  on the command line to use the libc++ standard library instead
  [-Wstdlibcxx-not-found]

  1 warning generated.

  Linking CXX executable cmTC_af3d5

  /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script
  CMakeFiles/cmTC_af3d5.dir/link.txt --verbose=1


  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  -arch x86_64 -isysroot
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.07.sdk
  -mmacosx-version-min=10.7 -Wl,-search_paths_first
  -Wl,-headerpad_max_install_names
  CMakeFiles/cmTC_af3d5.dir/testCXXCompiler.cxx.o -o cmTC_af3d5

  clang: warning: libstdc++ is deprecated; move to libc++ with a minimum
  deployment target of OS X 10.9 [-Wdeprecated]

  ld: library not found for -lstdc++

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  make[1]: *** [cmTC_af3d5] Error 1

  make: *** [cmTC_af3d5/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:47 (project)


-- Configuring incomplete, errors occurred!
9
  • Technically, this is just a warning about usage of deprecated library. Unless you have another errors, the project is still usable. Also, have you performed clean reconfiguration (delete build directory and run cmake again) after updating Xcode?
    – Tsyvarev
    Sep 25, 2018 at 21:42
  • Yea, I tried building into a fresh folder so no cache or anything. I updated the question with the full error message at the bottom.
    – DSchana
    Sep 25, 2018 at 21:54
  • the CMakeLists.txt file probably has the reference to libstdc++ hardcoded. Sep 25, 2018 at 22:07
  • @BradAllred I checked the CMakeLists.txt. Couldn't find any reference to libstdc++. It's the SFML CMake file I'm trying to compile right now btw.
    – DSchana
    Sep 25, 2018 at 22:13
  • can you post a link (or contents) of the CMakeList.txt file Sep 25, 2018 at 22:16

1 Answer 1

3

Ok. Turns out I just needed to add set(CMAKE_CXX_FLAGS "-stdlib=libc++") to my CMakeLists.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.