Skip to content
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

CMake config fails on OS X #422

Closed
fduxiao opened this issue Sep 21, 2018 · 6 comments
Closed

CMake config fails on OS X #422

fduxiao opened this issue Sep 21, 2018 · 6 comments
Labels
cmake dumbness for a list of issues I will publish when I jettison this misengineered disaster
Milestone

Comments

@fduxiao
Copy link

fduxiao commented Sep 21, 2018

I always get this:

-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- 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 /usr/local/Cellar/cmake/3.12.2/share/cmake/Modules/CMakeTestCXXCompiler.cmake:45 (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/xiao/Desktop/libui/build/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/local/bin/gmake" "cmTC_806b4/fast"
    /usr/local/bin/gmake -f CMakeFiles/cmTC_806b4.dir/build.make CMakeFiles/cmTC_806b4.dir/build
    gmake[1]: Entering directory '/Users/xiao/Desktop/libui/build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_806b4.dir/testCXXCompiler.cxx.o
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.8   -o CMakeFiles/cmTC_806b4.dir/testCXXCompiler.cxx.o -c /Users/xiao/Desktop/libui/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_806b4
    /usr/local/Cellar/cmake/3.12.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_806b4.dir/link.txt --verbose=1
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.8 -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_806b4.dir/testCXXCompiler.cxx.o  -o cmTC_806b4 
    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)
    gmake[1]: *** [CMakeFiles/cmTC_806b4.dir/build.make:87: cmTC_806b4] Error 1
    gmake[1]: Leaving directory '/Users/xiao/Desktop/libui/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:121: cmTC_806b4/fast] Error 2
    

  

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


-- Configuring incomplete, errors occurred!
See also "/Users/xiao/Desktop/libui/build/CMakeFiles/CMakeOutput.log".
See also "/Users/xiao/Desktop/libui/build/CMakeFiles/CMakeError.log".

It seems that ld cannot find libstdc++ and if I follow the instruction switching to OS X 10.9 then everything works just well.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7193fbb..39f8fd7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
 # TODO figure out what other variables must be set with CACHE
 # TODO figure out if FORCE is needed here
 # TODO figure out whether STRING "" is best or if something else is better; also what FORCE does because I forget and later I say it's needed
-set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8" CACHE STRING "" FORCE)
+set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
 
 # we want to disable incremental linking
 # see also:

It's really trivial but you could find it here if you think it a practical solution and need a pull request.
And I don't think this is the same as #302 since I get the error during configuring. Maybe you could find some further relation between them.

@andlabs
Copy link
Owner

andlabs commented Sep 21, 2018

(freenode #macdev)

[12:05:15]  <ytain>	well according to the release notes for xcode 10, it says that libstdc++ was removed from the sdk and recommends switching to the libc++ cause it supports features from C++17 and C++20
[12:06:16]  <ytain>	and yeah, you can see the absence of the libstdc++ from that folder 'ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib'
[12:13:08]  <Eiam>	it also removed the ability to build i386
[12:13:23]  <Eiam>	worth keeping in mind if you are trying to go far back
[12:14:31]  <ytain>	indeed
[12:23:45]  <andlabs>	ugh
[12:23:55]  <andlabs>	well this is gonna be a problem...

This basically means the latest version of Xcode with the latest SDK can no longer build C++ software for 10.8 or earlier, and one of the sample programs is in C++

@mischnic
Copy link
Contributor

This basically means the latest version of Xcode with the latest SDK can no longer build C++ software for 10.8 or earlier, and one of the sample programs is in C++

We already use libc++ for the C++ example:

if(APPLE)
# since we use a deployment target of 10.8, the non-C++11-compliant libstdc++ is chosen by default; we need C++11
# see issue #302 for more details
target_compile_options(cpp-multithread PRIVATE --stdlib=libc++)
target_link_libraries(cpp-multithread --stdlib=libc++)
endif()

This error is just the cmake test failing so I guess we need to set the stdlib globally?
In the past libc++ was supported on 10.7+, not sure why it's now suggesting 10.9.

libc++ cause it supports features from C++17 and C++20

Also for C++11.

@mischnic
Copy link
Contributor

Corresponding CMake issue: https://gitlab.kitware.com/cmake/cmake/issues/18396

@andlabs
Copy link
Owner

andlabs commented Feb 16, 2019

Well CMake has been patched, now we just have to wait for the patch to go live...

@andlabs
Copy link
Owner

andlabs commented Feb 18, 2019

Judging from the commit in question (https://gitlab.kitware.com/cmake/cmake/commit/8af334f5baa1a628895571491f67a4f7d9483d9b) 3.14.0 will be the first fixed version of cmake.

@andlabs
Copy link
Owner

andlabs commented Apr 8, 2019

The switch to meson has happened; closing.

@andlabs andlabs closed this as completed Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake dumbness for a list of issues I will publish when I jettison this misengineered disaster
Projects
None yet
Development

No branches or pull requests

3 participants