freesig / cpal

Audio player in pure Rust
0 stars 0 forks source link

`asio-sys` build script error - `windows.h` file not found #7

Closed mitchmindtree closed 6 years ago

mitchmindtree commented 6 years ago
   Compiling asio-sys v0.1.0 (file:///C:/Users/mindtree/programming/rust/cpal/asio-sys)
error: failed to run custom build command for `asio-sys v0.1.0 (file:///C:/Users/mindtree/programming/rust/cpal/asio-sys)`
process didn't exit successfully: `C:\Users\mindtree\programming\rust\cpal\target\debug\build\asio-sys-0003e87bc8d0b79d\build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-lib=dylib=ole32
cargo:rustc-link-lib=dylib=User32
cargo:rustc-link-search=C:\Users\mindtree\programming\rust\cpal\target\debug\build\asio-sys-16161e38d95f61cf\out
cargo:rustc-link-lib=static=asio

--- stderr
C:\Users\mindtree\.asio\asiosdk2.3.1 svnrev312937\ASIOSDK2.3.1\/host\asiodrivers.h:12:10: fatal error: 'windows.h' file not found
C:\Users\mindtree\.asio\asiosdk2.3.1 svnrev312937\ASIOSDK2.3.1\/host\asiodrivers.h:12:10: fatal error: 'windows.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', libcore\result.rs:945:5
stack backtrace:
   0: std::sys::windows::backtrace::set_frames
             at C:\projects\rust\src\libstd\sys\windows\backtrace\mod.rs:104
   1: std::sys::windows::backtrace::set_frames
             at C:\projects\rust\src\libstd\sys\windows\backtrace\mod.rs:104
   2: std::sys_common::backtrace::_print
             at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71
   3: std::sys_common::backtrace::_print
             at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71
   4: std::panicking::default_hook::{{closure}}
             at C:\projects\rust\src\libstd\panicking.rs:211
   5: std::panicking::default_hook
             at C:\projects\rust\src\libstd\panicking.rs:227
   6: std::panicking::rust_panic_with_hook
             at C:\projects\rust\src\libstd\panicking.rs:475
   7: std::panicking::continue_panic_fmt
             at C:\projects\rust\src\libstd\panicking.rs:390
   8: std::panicking::rust_begin_panic
             at C:\projects\rust\src\libstd\panicking.rs:325
   9: core::panicking::panic_fmt
             at C:\projects\rust\src\libcore\panicking.rs:77
  10: core::result::unwrap_failed<()>
             at C:\projects\rust\src\libcore\macros.rs:26
  11: core::result::Result<bindgen::Bindings, ()>::expect<bindgen::Bindings,()>
             at C:\projects\rust\src\libcore\result.rs:809
  12: build_script_build::create_bindings
             at .\build.rs:144
  13: build_script_build::main
             at .\build.rs:47
  14: std::rt::lang_start::{{closure}}<()>
             at C:\projects\rust\src\libstd\rt.rs:74
  15: std::rt::lang_start_internal::{{closure}}
             at C:\projects\rust\src\libstd\rt.rs:59
  16: std::rt::lang_start_internal::{{closure}}
             at C:\projects\rust\src\libstd\rt.rs:59
  17: panic_unwind::__rust_maybe_catch_panic
             at C:\projects\rust\src\libpanic_unwind\lib.rs:105
  18: std::panicking::try
             at C:\projects\rust\src\libstd\panicking.rs:289
  19: std::panicking::try
             at C:\projects\rust\src\libstd\panicking.rs:289
  20: std::panicking::try
             at C:\projects\rust\src\libstd\panicking.rs:289
  21: std::rt::lang_start<()>
             at C:\projects\rust\src\libstd\rt.rs:74
  22: main
  23: invoke_main
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:64
  24: invoke_main
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:64
  25: BaseThreadInitThunk
  26: RtlUserThreadStart
mitchmindtree commented 6 years ago

Seems like this might be relevant https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2017

mitchmindtree commented 6 years ago

Kind of related https://github.com/rust-lang-nursery/rust-bindgen/issues/1226

mitchmindtree commented 6 years ago

Ahhh hold up, I DLd clang 7 but it looks like rust-bindgen uses 6 https://github.com/rust-lang-nursery/rust-bindgen/blob/master/Cargo.toml Tom do you remember needing a specific version of clang?

Could be worth double checking these vars too https://github.com/KyleMayes/clang-sys/blob/master/README.md#environment-variables

freesig commented 6 years ago

Tom do you remember needing a specific version of clang?

No I used clang 7 and it worked. I'm pretty sure clang is backwards compatible

freesig commented 6 years ago

This might be relevant even if it is out of date.

I have used this same setup on 3 different machines and it's worked. I'm wondering if there was maybe some option needed when installing visual studio c++ tools. Also I selected include LLVM in all users PATH. Not sure if that is relevant.

freesig commented 6 years ago

This post gives a really good summary of how to do it.

mitchmindtree commented 6 years ago

It looks like LLVM is already in my path:

PS C:\Users\mindtree\programming\rust\cpal> $env:PATH
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\WINDOWS\System32\OpenSSH\;C:\Users\mindtree\.cargo\bin;C:\Users\mindtree\AppData\Local\Microsoft\WindowsApps;C:\Program Files\LLVM\bin

I can confirm that it's visible in the current powershell command line environment by running clang --help.

I'll keep looking into this once I get passed #14.

freesig commented 6 years ago

Can you compile a super simple hello_world.cpp with clang?

mitchmindtree commented 6 years ago

Agh no I can't actually:

PS C:\Users\mindtree> clang .\hello_world.cpp -o hello_world
clang.exe: warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt [-Wmsvc-not-found]
.\hello_world.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
1 error generated.
mitchmindtree commented 6 years ago

I'll read over the posts more closely.

freesig commented 6 years ago

Can you try that from one of the developer command prompt. I think it's the "native" one that works for me

On Sun., 14 Oct. 2018, 9:16 pm mitchmindtree, notifications@github.com wrote:

I'll read over the posts more closely.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/freesig/cpal/issues/7#issuecomment-429612726, or mute the thread https://github.com/notifications/unsubscribe-auth/AG8utlA13wn_jX5EO2qAT_P6Vl4TnBf9ks5ukw8YgaJpZM4XZXUR .

mitchmindtree commented 6 years ago

Do you mean try it with the regular windows cmd prompt rather than powershell? Just tried and I et the exact same error.

I'm going to try and install the visual c++ build tools again - they were installed on this so long ago that I don't remember what that setup was like.

mitchmindtree commented 6 years ago

Alright, up to a new error!

   Compiling asio-sys v0.1.0 (file:///C:/Users/mindtree/programming/rust/cpal/asio-sys)
error: failed to run custom build command for `asio-sys v0.1.0 (file:///C:/Users/mindtree/programming/rust/cpal/asio-sys)`
process didn't exit successfully: `C:\Users\mindtree\programming\rust\cpal\asio-sys\target\debug\build\asio-sys-422339b3d3fcf882\build-script-build` (exit code: 101)
--- stdout
error: IO error for operation on C:\Users\mindtree\.asio\ASIOSDK2.3.1\host: The system cannot find the path specified. (os error 3)
error: IO error for operation on C:\Users\mindtree\.asio\ASIOSDK2.3.1\host/pc: The system cannot find the path specified. (os error 3)
error: IO error for operation on C:\Users\mindtree\.asio\ASIOSDK2.3.1\common: The system cannot find the path specified. (os error 3)
TARGET = Some("x86_64-pc-windows-msvc")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-pc-windows-msvc")
CXX_x86_64-pc-windows-msvc = None
CXX_x86_64_pc_windows_msvc = None
HOST_CXX = None
CXX = None
CXXFLAGS_x86_64-pc-windows-msvc = None
CXXFLAGS_x86_64_pc_windows_msvc = None
HOST_CXXFLAGS = None
CXXFLAGS = None
DEBUG = Some("true")
running: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe" "/nologo" "/MD" "/Z7" "/I" "C:\\Users\\mindtree\\.asio\\ASIOSDK2.3.1/host" "/I" "C:\\Users\\mindtree\\.asio\\ASIOSDK2.3.1/common" "/I" "C:\\Users\\mindtree\\.asio\\ASIOSDK2.3.1/host/pc" "/I" "asio-link/helpers.hpp" "/W4" "/FoC:\\Users\\mindtree\\programming\\rust\\cpal\\asio-sys\\target\\debug\\build\\asio-sys-a327ee4db8fa5590\\out\\asio-link\\helpers.o" "/c" "asio-link/helpers.cpp"
helpers.cpp
c:\users\mindtree\programming\rust\cpal\asio-sys\asio-link\helpers.hpp(2): fatal error C1083: Cannot open include file: 'asiodrivers.h': No such file or directory
exit code: 2

--- stderr
thread 'main' panicked at '

Internal error occurred: Command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe" "/nologo" "/MD" "/Z7" "/I" "C:\\Users\\mindtree\\.asio\\ASIOSDK2.3.1/host" "/I" "C:\\Users\\mindtree\\.asio\\ASIOSDK2.3.1/common" "/I" "C:\\Users\\mindtree\\.asio\\ASIOSDK2.3.1/host/pc" "/I" "asio-link/helpers.hpp" "/W4" "/FoC:\\Users\\mindtree\\programming\\rust\\cpal\\asio-sys\\target\\debug\\build\\asio-sys-a327ee4db8fa5590\\out\\asio-link\\helpers.o" "/c" "asio-link/helpers.cpp" with args "cl.exe" did not execute successfully (status code exit code: 2).

', C:\Users\mindtree\.cargo\registry\src\github.com-1ecc6299db9ec823\cc-1.0.25\src\lib.rs:2260:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
freesig commented 6 years ago

This link explains how to use vsvarsall.bat

mitchmindtree commented 6 years ago

OK so back to the original windows.h error!

The windows.h error is fixed by using a specific command prompt, in my case:

Select Visual C== 2015 x64 Native Build Tools Command Prompt

which can be found via the start menu.

@freesig says this runs a .bat file that sets a bunch of environment variables.