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

weird symlinking error on windows? #1120

Closed
CelestialCrafter opened this issue Nov 8, 2024 · 6 comments
Closed

weird symlinking error on windows? #1120

CelestialCrafter opened this issue Nov 8, 2024 · 6 comments
Labels
🪲 bug Something isn't working

Comments

@CelestialCrafter
Copy link

hi! im getting an error while building my project on windows, but it builds fine on linux.

C:\Users\Celestial\Documents\fenlu\nodes\sink-frontend>cargo build
   Compiling cxx-qt v0.7.0
error: failed to run custom build command for `cxx-qt v0.7.0`

Caused by:
  process didn't exit successfully: `C:\Users\Celestial\Documents\fenlu\nodes\sink-frontend\target\debug\build\cxx-qt-d42316ea98c17eb5\build-script-build` (exit code: 101)
  --- stdout
  cargo::rerun-if-changed=include/
  cargo::rerun-if-changed=include/connection.h
  cargo::rerun-if-changed=include/signalhandler.h
  cargo::rerun-if-changed=include/thread.h
  cargo::rerun-if-changed=include/threading.h
  cargo::rerun-if-changed=include/type.h
  cargo::rerun-if-changed=src/connection.rs
  cargo::rerun-if-changed=src/connection.cpp

  --- stderr
  thread 'main' panicked at C:\Users\Celestial\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cxx-qt-build-0.7.0\src\lib.rs:1026:25:
  Failed to create symlink `cxx-qt` for export_include_directory: C:\Users\Celestial\Documents\fenlu\nodes\sink-frontend\target\debug\build\cxx-qt-2f7fe7d391714b2a\out\include\cxx-qt
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

the directory exists, and the error isnt that detailed, so i dont really know what to do.
here's my build.rs:

use cxx_qt_build::{CxxQtBuilder, QmlModule};

fn main() {
    CxxQtBuilder::new()
        .qt_module("Network")
        .qml_module(QmlModule {
            uri: "sinkfrontend",
            rust_files: &["src/qt/media.rs", "src/qt/actions.rs",],
            qml_files: &["qml/main.qml", "qml/Media.qml", "qml/MediaBackground.qml", "qml/MediaDetails.qml", "qml/CustomScrollGridView.qml", "qml/ActionsContextMenu.qml"],
            ..Default::default()
        })
        .build();
}

thank you!

@CelestialCrafter
Copy link
Author

contents of directory:

C:\Users\Celestial\Documents\fenlu\nodes\sink-frontend\target\debug\build\cxx-qt-2f7fe7d391714b2a\out\include\cxx-qt>ls
connection.h  signalhandler.h  thread.h  threading.h  type.h

@ahayzen-kdab ahayzen-kdab added the 🪲 bug Something isn't working label Nov 8, 2024
@ahayzen-kdab
Copy link
Collaborator

Symlinks are "fun" on Windows and are a privileged action on Windows, have you tried enabling Developer Mode, granting the SeCreateSymbolicLinkPrivilege privilege, or running the process as an administrator as described in the Rust docs.

https://doc.rust-lang.org/stable/std/os/windows/fs/fn.symlink_dir.html#limitations

@CelestialCrafter
Copy link
Author

worked! thank you

@jnbooth
Copy link
Contributor

jnbooth commented Nov 26, 2024

The symlinks can cause other things to break on Windows as well, such as the compiler not being able to find include files inside the cxx-qt-lib/ folder. I would also prefer not to need to include a section about enabling Developer Mode in the README of every project I use cxx-qt for.

@ahayzen-kdab, if I were to create a PR for cxx-qt-build to copy header files rather than symlinking their directories, would that be a welcome change? I also noticed a comment in its source code: "TODO: If it's neither unix nor windows, we should probably just deep-copy the dependency headers into our own include directory." It seems like symlinking is more trouble than it's worth.

@ahayzen-kdab
Copy link
Collaborator

Are symlinks really that broken on Windows? :-( Or is it a separate bug that include files are not working, it might just need to be passing a resolved path or something.

At the moment I'd prefer to at least keep symlinking on Linux/UNIX systems, maybe on Windows we can either deep copy or detect when symlinks aren't going to work and fallback.

We should also note that we are about to refactor the build system code during the 0.8 cycle, so something to consider @LeonMatthesKDAB

@LeonMatthesKDAB
Copy link
Collaborator

@jnbooth Of course not having to enable developer mode would be good.
So I'm happy to accept a PR that implements the symlink_directory function in cxx-qt-build with a deep-copy on windows and other systems.
As long as it keeps the symlinking on unix, as there it's the best solution.
While you're at it, it would also be good to move that function into the dir module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants