slint-ui / slint-cpp-template

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

`cmake -B` is not working right #1

Closed DaMilyutin closed 3 years ago

DaMilyutin commented 3 years ago

Hi, I've discovered sixty fps few days ago. Trying to build this C++ project. And I can't even generate with CMake: cmake -B build this step gives a bunch of errors. CMakeOutput.log

I have MSVS2019 installed. I also tried to build app with VS code. Saw something similar. How can I make it work?

tronical commented 3 years ago

Hmm, it appears that you're using a nightly version of Rust. Does it work if you switch to the stable version? (rustup default stable)

(Not saying that we shouldn't support nightly, just curious as that's the only thing I can see that's different off the top of my hat)

DaMilyutin commented 3 years ago

Nope, didn't work. build-log.txt

ogoffart commented 3 years ago

Your rust is still to old, it should be at least 1.54 or newer and you are using 1.44

That said, that does not explain the build faillure you have.

libcore-83168dc81ba47b29.rlib(core-83168dc81ba47b29.core.e1ci3hm7-cgu.0.rcgu.o) : error LNK2001: ????????????? ??????? ?????? memcpy.
          build_script_build-b59e9d5302d825d9.build_script_build.15mj12rr-cgu.4.rcgu.o : error LNK2001: ????????????? ??????? ?????? memcpy.
         [...]
          libstd-fae0adc6a4bf13fc.rlib(std-fae0adc6a4bf13fc.std.3iar8zjk-cgu.0.rcgu.o) : error LNK2001: ????????????? ??????? ?????? __CxxFrameHandler3.
        [...]

This is a link failure. There are some encoding issue in the error text, but this might mean that it doesn't find quite some standard symbol, so there is something wrong with the rust installation. I would update rust and see if that fix the problem. If not, are you able to try a rust hello world?

tronical commented 3 years ago

Since the build error happens at corrosion initialisation time (before sixtyfps), another thing to try would be a plain corrosion build with cmake, by cloning https://github.com/AndrewGaspar/corrosion and building it with cmake.

For the hello world, you can try this:

  1. cargo new helloworld
  2. cd helloworld
  3. cargo build
DaMilyutin commented 3 years ago

Actually corrosion build from git fails...

git clone https://github.com/AndrewGaspar/corrosion.git
# Optionally, specify -DCMAKE_INSTALL_PREFIX=<target-install-path>. You can install Corrosion anyway
cmake -Scorrosion -Bbuild -DCMAKE_BUILD_TYPE=Release # <---- this step fails
cmake --build build --config Release
# This next step may require sudo or admin privileges if you're installing to a system location,
# which is the default.
cmake --install build --config Release

Should I create issue to AndrewGaspar? corrosion-log.txt

ogoffart commented 3 years ago

I would try to see if this is not a problem with your rust setup. Are you able to build a simple hello world program with rust?

DaMilyutin commented 3 years ago

actually this fails, too... main.rs

fn main() {
    println!("Hello, world!");
}

rust-hello.log

DaMilyutin commented 3 years ago

I've tried rust example some time ago and it worked fine. I'm confused.

ogoffart commented 3 years ago

i don't know what the problem could be. perhaps some incompatibility between the Windows Runtime library and the rust compiler. You can try to upgrade rust and see if that solves the problem.

DaMilyutin commented 3 years ago

I'll try this https://stackoverflow.com/questions/55603111/unable-to-compile-rust-hello-world-on-windows-linker-link-exe-not-found maybe it will help

upd: it worked! Hello world is ok. I think I got why it didn't work well. I used "Developer Comand Prompt for VS 2019"... and it still don't gives result, "Console Z" is ok. So I guess stackoverflow advice above is not needed at all.

now I will try cpp-template.

cmake -B // worked

but...

cmake --build build // gave error cmake-build.log

ogoffart commented 3 years ago

Yes, now the error is because your version of rustc is too old, as I said, you need at least 1.54

DaMilyutin commented 3 years ago

Sorry. I was to focused on link errors and lost sight of rustc version. Updated rustc. Now it builds!

Thank you for your guidance and patience!

Note, to run exe I had to copy dll into same directory where exe is placed. With this VS Code runs, too.

Offtopic question. By your estimation does sixty-fps require me to study Rust in depth? Can I rely just on my knowledge of C++ and intuition of Qt/QML?

ogoffart commented 3 years ago

By your estimation does sixty-fps require me to study Rust in depth?

No, rust is only used for the implementation of the framework. So it is only required to compile the SixtyFPS libraries. but we expose an idiomatic C++ API, so no knowledge of rust required. We plan on providing binary packages as well so no rust will be needed at all.