C++/STD - 错误:“路径”不可用:在 macOS 10.15 中引入

问题描述 投票:0回答:1

我正在我的 MacBook M2 Max、MacOS 13.5 Ventura 上构建 QCefView

这是我的 CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)

project(CEFTest VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
add_subdirectory(QCefView)

set(PROJECT_SOURCES
        main.cpp
        mainwindow.cpp
        mainwindow.h
        mainwindow.ui
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    qt_add_executable(CEFTest
        MANUAL_FINALIZATION
        ${PROJECT_SOURCES}
    )
# Define target properties for Android with Qt 6 as:
#    set_property(TARGET CEFTest APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
#                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
    if(ANDROID)
        add_library(CEFTest SHARED
            ${PROJECT_SOURCES}
        )
# Define properties for Android with Qt 5 after find_package() calls as:
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    else()
        add_executable(CEFTest
            ${PROJECT_SOURCES}
        )
    endif()
endif()

target_link_libraries(CEFTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
  set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.CEFTest)
endif()
set_target_properties(CEFTest PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)
install(TARGETS CEFTest
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(CEFTest)
endif()

构建时出现此错误:

[ 95%] Building CXX object QCefView/src/CMakeFiles/QCefView.dir/details/QCefConfigPrivate.cpp.o
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:59:58: error: 'path' is unavailable: introduced in macOS 10.15
inline QString fromFilesystemPath(const std::filesystem::path &path)
                                                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:64:40: error: 'native' is unavailable: introduced in macOS 10.15
    return QString::fromStdString(path.native());
                                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:1193:22: note: 'native' has been explicitly marked unavailable here
  const string_type& native() const noexcept { return __pn_; }
                     ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:68:25: error: 'path' is unavailable: introduced in macOS 10.15
inline std::filesystem::path toFilesystemPath(const QString &path)
                        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:70:29: error: 'path' is unavailable: introduced in macOS 10.15
    return std::filesystem::path(reinterpret_cast<const char16_t *>(path.cbegin()),
                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:70:12: error: 'path<const char16_t *>' is unavailable: introduced in macOS 10.15
    return std::filesystem::path(reinterpret_cast<const char16_t *>(path.cbegin()),
           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:953:3: note: 'path<const char16_t *>' has been explicitly marked unavailable here
  path(_InputIt __first, _InputIt __last, format = format::auto_format) {
  ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:70:12: error: 'path' is unavailable: introduced in macOS 10.15
    return std::filesystem::path(reinterpret_cast<const char16_t *>(path.cbegin()),
           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:953:3: note: 'path' has been explicitly marked unavailable here
  path(_InputIt __first, _InputIt __last, format = format::auto_format) {
  ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:70:12: error: '~path' is unavailable: introduced in macOS 10.15
    return std::filesystem::path(reinterpret_cast<const char16_t *>(path.cbegin()),
           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:968:3: note: '~path' has been explicitly marked unavailable here
  ~path() = default;
  ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:128:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemFileName() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:190:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemSymLinkTarget() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:195:29: error: 'path' is unavailable: introduced in macOS 10.15
    static std::filesystem::path filesystemSymLinkTarget(const T &fileName)
                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:129:14: error: '~path' is unavailable: introduced in macOS 10.15
    { return QtPrivate::toFilesystemPath(fileName()); }
             ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:968:3: note: '~path' has been explicitly marked unavailable here
  ~path() = default;
  ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:8:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfile.h:192:16: error: '~path' is unavailable: introduced in macOS 10.15
        return QtPrivate::toFilesystemPath(symLinkTarget());
               ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:968:3: note: '~path' has been explicitly marked unavailable here
  ~path() = default;
  ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:82:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemFilePath() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:84:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemAbsoluteFilePath() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:86:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemCanonicalFilePath() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:100:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemPath() const { return QtPrivate::toFilesystemPath(path()); }
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:101:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemAbsolutePath() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:103:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemCanonicalPath() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
In file included from /Users/venelin/Development/CEFTest/CEFTest/QCefView/src/details/QCefConfigPrivate.cpp:5:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/QDir:1:
In file included from /Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qdir.h:9:
/Users/venelin/Qt/6.6.0/macos/lib/QtCore.framework/Headers/qfileinfo.h:134:22: error: 'path' is unavailable: introduced in macOS 10.15
    std::filesystem::path filesystemSymLinkTarget() const
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/c++/v1/filesystem:909:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [QCefView/src/CMakeFiles/QCefView.dir/details/QCefConfigPrivate.cpp.o] Error 1
make[1]: *** [QCefView/src/CMakeFiles/QCefView.dir/all] Error 2
make: *** [all] Error 2
☁  build  

知道为什么我会收到此错误以及如何修复它吗?

已经尝试过:

cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15  ..
,但似乎没有任何改变。

c++ filesystems std
1个回答
0
投票
  1. std::filesystem::path 仅支持 macOS 10.15+
  2. 适用于 Qt 版本 < 6.5, Qt doesn't use std::filesystem::path so that it can support macOS version below 10.15
  3. 从 6.5 开始 Qt 仅支持 macOS 11+,并且 Qt 使用 std::filesystem::path

但是 QCefView 仍然需要支持 macOS 10.13+,如果要使用 Qt 6.5+ 编译 QCefView,则意味着最低部署目标应该是 macOS 11.0+。

请参考:https://github.com/CefView/QCefView/issues/341

© www.soinside.com 2019 - 2024. All rights reserved.