slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

qttypes error #4809

Closed Mathijs-Bakker closed 6 months ago

Mathijs-Bakker commented 6 months ago

I can not cargo build on MacOS 12.6 as I get the following error:

The following warnings were emitted during compilation:

warning: qttypes@0.2.11: xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
warning: qttypes@0.2.11: xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
warning: qttypes@0.2.11: macOS deployment target (10.7) too low, it will be increased
warning: qttypes@0.2.11: clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
warning: qttypes@0.2.11: /Users/##/Repositories/slint/target/debug/build/qttypes-9c458679a7514d34/out/rust_cpp/cpp_closures.cpp:5:10: fatal error: 'new' file not found
warning: qttypes@0.2.11: #include <new> // For placement new
warning: qttypes@0.2.11:          ^~~~~
warning: qttypes@0.2.11: 1 error generated.

error: failed to run custom build command for `qttypes v0.2.11`

Caused by:
  process didn't exit successfully: `/Users/##/Repositories/slint/target/debug/build/qttypes-82429e39e59cc12e/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=QT_INCLUDE_PATH
  cargo:rerun-if-env-changed=QT_LIBRARY_PATH
  cargo:rerun-if-env-changed=QMAKE
  TARGET = Some("x86_64-apple-darwin")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-apple-darwin")
  cargo:rerun-if-env-changed=CXX_x86_64-apple-darwin
  CXX_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_x86_64_apple_darwin
  CXX_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
  cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
  cargo:warning=macOS deployment target (10.7) too low, it will be increased
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-apple-darwin
  CXXFLAGS_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_apple_darwin
  CXXFLAGS_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:warning=clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
  cargo:warning=/Users/##/Repositories/slint/target/debug/build/qttypes-9c458679a7514d34/out/rust_cpp/cpp_closures.cpp:5:10: fatal error: 'new' file not found
  cargo:warning=#include <new> // For placement new
  cargo:warning=         ^~~~~
  cargo:warning=1 error generated.

  --- stderr

  error occurred: ToolExecError: Command env -u IPHONEOS_DEPLOYMENT_TARGET "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "--target=x86_64-apple-darwin" "-mmacosx-version-min=10.7" "-I" "/Users/##/.cargo/registry/src/index.crates.io-6f17d22bba15001f/qttypes-0.2.11" "-I" "/usr/local/include" "-Wall" "-Wextra" "-F" "/usr/local/lib" "-std=c++17" "-o" "/Users/##/Repositories/slint/target/debug/build/qttypes-9c458679a7514d34/out/ba11d0a4c22d6692-cpp_closures.o" "-c" "/Users/##/Repositories/slint/target/debug/build/qttypes-9c458679a7514d34/out/rust_cpp/cpp_closures.cpp" with args "c++" did not execute successfully (status code exit status: 1).

I updated QT for Mac. But still I have the same issue.

The only issues with Qt w/ MacOS I found: #3819 #3921

ogoffart commented 6 months ago

https://github.com/slint-ui/slint/pull/4566 should workaround such issue by disabling the Qt backend by default on Mac.

But the problem is that clang can't find standard library header:

clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead

That is really strange and i can't explain it. Perhaps something wrong with your compiler.

Mathijs-Bakker commented 6 months ago

OK, I solved it...

I can't put my finger on it, but I suspect Homebrew is also installing command-line-tools (next to Xcode) and messes things up with the path to the SDK.

In my case I had to change the /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk path to/with:

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Closing this issue and thanks!