Skip to content

Windows Build error #109

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

Closed
wangjia184 opened this issue May 30, 2025 · 5 comments
Closed

Windows Build error #109

wangjia184 opened this issue May 30, 2025 · 5 comments

Comments

@wangjia184
Copy link

Thanks for bringing this amazing project.
I successfully built it on Linux. But on Windows, I encountered the following error. it seems somethign wrong with linking. I am not sure what the problem is.

error.log

@csmoe
Copy link
Contributor

csmoe commented Jun 3, 2025

cefclient is unneeded, actually. Try this patch #113

@wangjia184
Copy link
Author

Thanks @csmoe

I updated my Cargo.toml to try the branch excluded cefclient and testcases.

cef = { git = "https://github.com/csmoe/tauri-cef-rs.git", branch = "only-build-wrapper", package = "cef" }
cef-dll-sys = { git = "https://github.com/csmoe/tauri-cef-rs.git", branch = "only-build-wrapper", package = "cef-dll-sys" }

And I configured environment variables in my workspace's .cargo/config.toml

[env]
CEF_PATH = { value = "cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64", relative = true, force = true }
LD_LIBRARY_PATH = { value = "cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64\\Release\\", relative = true, force = true }
LIBRARY_PATH  = { value = "cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64\\Release\\", relative = true, force = true }

Also I tried to add a library search path in my build.rs

    println!(
        "cargo:rustc-link-search=native={}",
        source_dir.join("Release").display()
    );

The build fails with a linking error.

Caused by:
  process didn't exit successfully: `F:\projects\live-board\target\debug\build\web-renderer-08b20ca968fc8d6a\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=F:\projects\live-board\www/*
  cargo:rerun-if-changed=F:\projects\live-board\cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64/*
  cargo:rustc-link-search=native=F:\projects\live-board\cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64\Release
  cargo:rerun-if-changed=F:\projects\live-board\Resources/*

  --- stderr

  thread 'main' panicked at web-renderer\build.rs:30:40:
  called `Result::unwrap()` on an `Err` value: The system cannot find the path specified. (os error 3)
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: could not find native static library `cef_sandbox`, perhaps an -L flag is missing?

error: could not compile `cef-dll-sys` (lib) due to 1 previous error

I do see cef_sandbox.lib is located in cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64\Release\ . But seems cef-dll-sys cannot find it.

I checked the build.rs(https://github.com/csmoe/tauri-cef-rs/blob/only-build-wrapper/sys/build.rs) from cef-dll-sys relies on CEF_PATH to determine the path.

Then I changed CEF_PATH from

CEF_PATH = { value = "cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64", relative = true, force = true }

To

CEF_PATH = { value = "cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64\\Release", relative = true, force = true }

It results in another error.


  --- stderr
  CMake Warning:
    Ignoring extra path from command line:

     "F:\projects\live-board\cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64\Release\"


  CMake Error: The source directory "F:/projects/live-board/cef_binary_135.0.22+g442c600+chromium-135.0.7049.115_windows64/Release" does not appear to contain CMakeLists.txt.
  Specify --help for usage, or press the help button on the CMake GUI.

  thread 'main' panicked at C:\Users\Jerry\.cargo\registry\src\mirrors.ustc.edu.cn-38d0e5eb5da2abae\cmake-0.1.54\src\lib.rs:1119:5:

@csmoe
Copy link
Contributor

csmoe commented Jun 3, 2025

LD_LIBRARY_PATH/LIBRARY_PATH are used in *nix platform, will not work on windows.
And you don't have to write your own build.rs to link cef libraries. Could you paste your build.rs here?

btw cef-dll-sys is already exported in cef(cef::sys), no needded to import as extra dependencies in Cargo.toml.

@wravery
Copy link
Contributor

wravery commented Jun 3, 2025

Also, if you set CEF_PATH without running export-cef-dir to put it in that location, it won't work. It'll be slower for the initial build, but if you just unset all of those environment variables that you currently have and run cargo with a dependency on the cef crate, it should automatically use the out_dir from the cef-dll-sys crate build. Alternatively, make sure you're following the instructions for Windows when you build on Windows.

The path to your target directory may also be too long for Windows, particularly if you have the full cef_binary_135.0.22... package name in there.

@wangjia184
Copy link
Author

Thanks @wravery, export-cef-dir works.

cargo install export-cef-dir --version 135.0.22 --force
export-cef-dir --force $env:USERPROFILE/.local/share/cef

I downloaded the CEF files from https://cef-builds.spotifycdn.com/index.html#windows64:135, it seems the folder structure is differfent from the ones I got from export-cef-dir.

Anyway, the issue is fixed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants