slint-ui / slint-cpp-template

A template for a C++ Application using Slint
https://slint.dev
MIT License
45 stars 11 forks source link

Error while building on mac os #10

Closed andrewssobral closed 1 year ago

andrewssobral commented 1 year ago

I'm trying to build this template on my mac, but I am getting the following errors: Do you know how to fix this?

Copying byproducts `libslint_cpp.dylib` to /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-build
[  0%] Built target _cargo-build_slint-cpp
[  0%] Built target cargo-build_slint-cpp
[ 33%] Generating appwindow.h
[ 66%] Building CXX object CMakeFiles/my_application.dir/src/main.cpp.o
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/src/main.cpp:1:
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/appwindow.h:5:
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:156:19: error: no template named 'invocable' in namespace 'std'
    template<std::invocable<RenderingState, GraphicsAPI> F>
             ~~~~~^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:157:69: error: unknown type name 'F'
    std::optional<SetRenderingNotifierError> set_rendering_notifier(F callback) const
                                                                    ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:174:19: error: no type named 'invocable' in namespace 'std'
    template<std::invocable F>
             ~~~~~^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:175:61: error: template argument for template type parameter must be a type
        requires(std::is_convertible_v<std::invoke_result_t<F>, CloseRequestResponse>)
                                                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:3938:17: note: template parameter is declared here
template <class _Fn, class... _Args>
                ^
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/src/main.cpp:1:
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/appwindow.h:5:
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:95:65: error: use of undeclared identifier 'inner'
        cbindgen_private::slint_windowrc_clone(&adopted_inner, &inner);
                                                                ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:97:64: error: use of undeclared identifier 'inner'
    WindowAdapterRc() { cbindgen_private::slint_windowrc_init(&inner); }
                                                               ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:98:65: error: use of undeclared identifier 'inner'
    ~WindowAdapterRc() { cbindgen_private::slint_windowrc_drop(&inner); }
                                                                ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:99:75: error: no member named 'inner' in 'slint::private_api::WindowAdapterRc'
    WindowAdapterRc(const WindowAdapterRc &other) : WindowAdapterRc(other.inner) { }
                                                                    ~~~~~ ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:106:52: error: use of undeclared identifier 'inner'
            cbindgen_private::slint_windowrc_drop(&inner);
                                                   ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:107:59: error: no member named 'inner' in 'slint::private_api::WindowAdapterRc'
            cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
                                                    ~~~~~ ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:107:67: error: use of undeclared identifier 'inner'; did you mean 'index'?
            cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
                                                                  ^~~~~
                                                                  index
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/strings.h:73:7: note: 'index' declared here
char    *index(const char *, int) __POSIX_C_DEPRECATED(200112L);
         ^
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/src/main.cpp:1:
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/appwindow.h:5:
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:112:46: error: use of undeclared identifier 'inner'
    void show() const { slint_windowrc_show(&inner); }
                                             ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:113:46: error: use of undeclared identifier 'inner'
    void hide() const { slint_windowrc_hide(&inner); }
                                             ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:114:65: error: use of undeclared identifier 'inner'
    bool is_visible() const { return slint_windowrc_is_visible(&inner); }
                                                                ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:116:74: error: use of undeclared identifier 'inner'
    float scale_factor() const { return slint_windowrc_get_scale_factor(&inner); }
                                                                         ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:117:81: error: use of undeclared identifier 'inner'
    void set_scale_factor(float value) const { slint_windowrc_set_scale_factor(&inner, value); }
                                                                                ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:119:79: error: use of undeclared identifier 'inner'
    bool dark_color_scheme() const { return slint_windowrc_dark_color_scheme(&inner); }
                                                                              ^
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:125:89: error: use of undeclared identifier 'inner'; did you mean 'index'?
                vtable::VRef<ComponentVTable> { &Component::static_vtable, c }, items, &inner);
                                                                                        ^~~~~
                                                                                        index
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/strings.h:73:7: note: 'index' declared here
char    *index(const char *, int) __POSIX_C_DEPRECATED(200112L);
         ^
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/src/main.cpp:1:
In file included from /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/appwindow.h:5:
/Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-src/api/cpp/include/slint.h:131:58: error: use of undeclared identifier 'inner'
        cbindgen_private::slint_windowrc_set_focus_item(&inner, &item_rc);
                                                         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/my_application.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/my_application.dir/all] Error 2
make: *** [all] Error 2
andrewssobral@macbookpro slint-cpp-template %

Additional info:

andrewssobral@macbookpro slint-cpp-template % cmake -B build
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Slint could not be located in the CMake module search path. Downloading it from Git and building it locally
-- Rust Toolchain: stable-x86_64-apple-darwin
-- Rust Target: x86_64-apple-darwin
-- Found Rust: /Users/andrewssobral/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc (found version "1.68.2") 
-- Using Corrosion as a subdirectory
-- Rust Toolchain: stable-x86_64-apple-darwin
-- Rust Target: x86_64-apple-darwin
-- Found Rust: /Users/andrewssobral/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc (found suitable version "1.68.2", minimum required is "1.66") 
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework   
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build
andrewssobral@macbookpro slint-cpp-template % clang++ --version
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
image
ogoffart commented 1 year ago

Thanks for filling an issue!

Apple clang version 12.0.5 (clang-1205.0.22.11)

I think that version of clang is too old. We need a compiler with C++20 support. Could you try to upgrade to the version 13 or 14 ?

andrewssobral commented 1 year ago

Hello @ogoffart ,

Just upgraded to clang version 14.0.0 and it works fine, thank you!

Copying byproducts `libslint_cpp.dylib` to /Users/andrewssobral/Projects/slint-ui/slint-cpp-template/build/_deps/slint-build
[  0%] Built target _cargo-build_slint-cpp
[  0%] Built target cargo-build_slint-cpp
[ 33%] Generating appwindow.h
[ 66%] Building CXX object CMakeFiles/my_application.dir/src/main.cpp.o
[100%] Linking CXX executable my_application
[100%] Built target my_application
andrewssobral@macbookpro slint-cpp-template %
andrewssobral@macbookpro slint-cpp-template % clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
image