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

Building for Windows 10 - 'cannot run ffmpeg build script' #27

Closed
Bougakov opened this issue May 18, 2020 · 8 comments
Closed

Building for Windows 10 - 'cannot run ffmpeg build script' #27

Bougakov opened this issue May 18, 2020 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed windows Windows support

Comments

@Bougakov
Copy link
Contributor

Hi. I've tried to build the project on Windows.

I've downloaded 64-bit distribution of Rust and installed it. I've also downloaded and installed Build Tools for Visual Studio 2019 (to obtain link.exe).

I've also downloaded an FFmpeg build with shared libraries and saved its contents straight to the Windows folder.

Build process breaks at media_info (audioserve builds just fine):

C:\Users\sanja\Downloads\audioserve-master\audioserve-master>cargo build --release --features partially-static
   Compiling winapi v0.3.8
   Compiling proc-macro2 v1.0.9
   Compiling syn v1.0.16
   Compiling memchr v2.3.3
   Compiling fnv v1.0.6
   Compiling winapi-build v0.1.1
   Compiling log v0.4.8
   Compiling libc v0.2.67
   Compiling lazy_static v1.4.0
   Compiling bytes v0.5.4
   Compiling slab v0.4.2
   Compiling winapi v0.2.8
   Compiling futures-core v0.3.4
   Compiling byteorder v1.3.4
   Compiling itoa v0.4.5
   Compiling proc-macro-nested v0.1.3
   Compiling typenum v1.11.2
   Compiling futures-sink v0.3.4
   Compiling iovec v0.1.4
   Compiling serde v1.0.104
   Compiling pin-project-lite v0.1.4
   Compiling pin-utils v0.1.0-alpha.4
   Compiling futures-io v0.3.4
   Compiling futures-task v0.3.4
   Compiling getrandom v0.1.14
   Compiling byte-tools v0.3.1
   Compiling bitflags v1.2.1
   Compiling version_check v0.9.1
   Compiling ident_case v1.0.1
   Compiling strsim v0.9.3
   Compiling autocfg v1.0.0
   Compiling matches v0.1.8
   Compiling httparse v1.3.4
   Compiling smallvec v1.2.0
   Compiling ppv-lite86 v0.2.6
   Compiling fake-simd v0.1.2
   Compiling opaque-debug v0.2.3
   Compiling base64 v0.11.0
   Compiling quick-error v1.2.3
   Compiling ryu v1.0.2
   Compiling percent-encoding v2.1.0
   Compiling cc v1.0.50
   Compiling utf-8 v0.7.5
   Compiling derive_builder v0.9.0
   Compiling try-lock v0.2.2
   Compiling native-tls v0.2.3
   Compiling mime v0.3.16
   Compiling unicode-width v0.1.7
   Compiling linked-hash-map v0.5.2
   Compiling media_info v0.1.4 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master\crates\media_info)
   Compiling tower-service v0.3.0
   Compiling regex-syntax v0.6.14
   Compiling dtoa v0.4.5
   Compiling vec_map v0.8.1
   Compiling strsim v0.8.0
   Compiling ego-tree v0.6.2
   Compiling untrusted v0.7.0
   Compiling spin v0.5.2
   Compiling bit-vec v0.6.1
   Compiling audioserve v0.12.1 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master)
   Compiling data-encoding v2.2.0
   Compiling kernel32-sys v0.2.2
   Compiling ws2_32-sys v0.2.1
   Compiling thread_local v1.0.1
   Compiling input_buffer v0.3.1
   Compiling http v0.2.0
   Compiling futures-channel v0.3.4
   Compiling block-padding v0.1.5
   Compiling unicase v2.6.0
   Compiling unicode-bidi v0.3.4
   Compiling indexmap v1.3.2
   Compiling unicode-normalization v0.1.12
   Compiling humantime v1.3.0
   Compiling c2-chacha v0.2.3
   Compiling textwrap v0.11.0
   Compiling yaml-rust v0.4.3
error: failed to run custom build command for `media_info v0.1.4 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master\crates\media_info)`

Caused by:
  process didn't exit successfully: `C:\Users\sanja\Downloads\audioserve-master\audioserve-master\target\release\build\media_info-8e411d9664ae1e6e\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'cannot run ffmpeg build script: Os { code: 193, kind: Other, message: "%1 is not a valid Win32 application." }', crates\media_info\build.rs:17:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish...
error: build failed

Unfortunately, I have zero experience with Rust, so I can only help with details but not with fixes. Any ideas on how to solve this? Thanks.

@Bougakov
Copy link
Contributor Author

I've realized that the error is caused by this line:

let rc =  process::Command::new("./build_ffmpeg.sh")

which refers to a clearly not a cross-platform Bash script.

Tried recompiling with no default features, got this:

C:\Users\sanja\Downloads\audioserve-master\audioserve-master>cargo build --release --no-default-features
   Compiling winapi v0.3.8
   Compiling syn v1.0.16
   Compiling log v0.4.8
   Compiling byteorder v1.3.4
   Compiling media_info v0.1.4 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master\crates\media_info)
   Compiling audioserve v0.12.1 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master)
   Compiling ring v0.16.11
   Compiling proc-macro2 v1.0.9
   Compiling memchr v2.3.3
   Compiling ws2_32-sys v0.2.1
   Compiling kernel32-sys v0.2.2
   Compiling libc v0.2.67
   Compiling serde v1.0.104
   Compiling http-body v0.3.1
   Compiling headers-core v0.2.0
   Compiling unicase v2.6.0
   Compiling proc-macro-nested v0.1.3
   Compiling typenum v1.11.2
   Compiling indexmap v1.3.2
   Compiling bitflags v1.2.1
   Compiling ryu v1.0.2
   Compiling httparse v1.3.4
   Compiling idna v0.2.0
   Compiling quote v1.0.2
   Compiling aho-corasick v0.7.9
   Compiling csv-core v0.1.10
   Compiling num_cpus v1.12.0
   Compiling want v0.3.0
   Compiling generic-array v0.12.3
   Compiling url v2.1.1
   Compiling regex v1.3.4
   Compiling mime_guess v2.0.3
   Compiling digest v0.8.1
   Compiling regex-automata v0.1.8
   Compiling block-buffer v0.7.3
   Compiling serde_test v1.0.104
   Compiling serde_json v1.0.48
   Compiling serde_yaml v0.8.11
   Compiling unicase_serde v0.1.0
   Compiling bstr v0.2.11
   Compiling sha-1 v0.8.2
   Compiling linked-hash-map v0.5.2 (https://github.com/izderadicka/linked-hash-map.git#e1361b36)
   Compiling net2 v0.2.33
   Compiling socket2 v0.3.11
   Compiling time v0.1.42
   Compiling atty v0.2.14
   Compiling winapi-util v0.1.3
   Compiling dirs-sys v0.3.4
   Compiling csv v1.1.3
   Compiling miow v0.2.1
   Compiling miow v0.3.3
   Compiling headers v0.3.1
   Compiling clap v2.33.0
   Compiling termcolor v1.1.0
   Compiling dirs v2.0.2
   Compiling mio v0.6.21
   Compiling env_logger v0.7.1
   Compiling mio-named-pipes v0.1.6
   Compiling proc-macro-hack v0.5.11
   Compiling tokio-macros v0.2.5
   Compiling pin-project-internal v0.4.8
   Compiling serde_derive v1.0.104
   Compiling futures-macro v0.3.4
   Compiling tokio v0.2.13
   Compiling futures-util v0.3.4
   Compiling tokio-util v0.2.0
   Compiling futures-executor v0.3.4
   Compiling h2 v0.2.1
   Compiling futures v0.3.4
   Compiling pin-project v0.4.8
   Compiling hyper v0.13.2
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\deps\\audioserve.audioserve.2d99onhz-cgu.0.rcgu.o" "/OUT:C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\deps\\audioserve.exe" "/OPT:REF,ICF" "/DEBUG" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\deps" "/LIBPATH:C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\build\\ring-e0c1d6ff572650b0\\out" "/LIBPATH:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\sanja\\AppData\\Local\\Temp\\rustcyGUHZN\\libring-fbbea91839df5bd6.rlib" "C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-bb027328a052d4db.rlib" "avformat.lib" "avutil.lib" "avcodec.lib" "ws2_32.lib" "kernel32.lib" "advapi32.lib" "cfgmgr32.lib" "credui.lib" "fwpuclnt.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "ntdll.lib" "ole32.lib" "opengl32.lib" "secur32.lib" "shell32.lib" "synchronization.lib" "user32.lib" "winspool.lib" "ws2_32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
  = note: LINK : fatal error LNK1181: cannot open input file 'avformat.lib'


error: aborting due to previous error

error: could not compile `audioserve`.

To learn more, run the command again with --verbose.

@Bougakov
Copy link
Contributor Author

Found the required *.lib files in https://ffmpeg.zeranoe.com/builds/win32/dev/, placed them into C:\Program Files\Rust stable MSVC 1.43\lib\rustlib\x86_64-pc-windows-msvc\lib. Got this:

C:\Users\sanja\Downloads\audioserve-master\audioserve-master>cargo build --release --no-default-features
   Compiling audioserve v0.12.1 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master)
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\deps\\audioserve.audioserve.2d99onhz-cgu.0.rcgu.o" "/OUT:C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\deps\\audioserve.exe" "/OPT:REF,ICF" "/DEBUG" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\deps" "/LIBPATH:C:\\Users\\sanja\\Downloads\\audioserve-master\\audioserve-master\\target\\release\\build\\ring-e0c1d6ff572650b0\\out" "/LIBPATH:C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\sanja\\AppData\\Local\\Temp\\rustcT8tEVS\\libring-fbbea91839df5bd6.rlib" "C:\\Program Files\\Rust stable MSVC 1.43\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-bb027328a052d4db.rlib" "avformat.lib" "avutil.lib" "avcodec.lib" "ws2_32.lib" "kernel32.lib" "advapi32.lib" "cfgmgr32.lib" "credui.lib" "fwpuclnt.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "ntdll.lib" "ole32.lib" "opengl32.lib" "secur32.lib" "shell32.lib" "synchronization.lib" "user32.lib" "winspool.lib" "ws2_32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
  = note: audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol av_log_set_level referenced in function _ZN3std4sync4once4Once9call_once28_$u7b$$u7b$closure$u7d$$u7d$17hbf90aef279e0415bE
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol av_register_all referenced in function _ZN3std4sync4once4Once9call_once28_$u7b$$u7b$closure$u7d$$u7d$17hbf90aef279e0415bE
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol avformat_close_input referenced in function _ZN4core3ptr13drop_in_place17h5027805d3a35590dE
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol av_dict_get referenced in function _ZN115_$LT$audioserve..services..audio_meta..libavformat..Info$u20$as$u20$audioserve..services..audio_meta..MediaInfo$GT$12get_chapters17h211a84aeb547fcdeE
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol avformat_alloc_context referenced in function _ZN10audioserve8services10audio_meta20get_audio_properties17hbe7eeea3bb9cd886E
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol avformat_open_input referenced in function _ZN10audioserve8services10audio_meta20get_audio_properties17hbe7eeea3bb9cd886E
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol avformat_find_stream_info referenced in function _ZN10audioserve8services10audio_meta20get_audio_properties17hbe7eeea3bb9cd886E
          audioserve.audioserve.2d99onhz-cgu.0.rcgu.o : error LNK2019: unresolved external symbol av_dict_count referenced in function _ZN10audioserve8services10audio_meta20get_audio_properties17hbe7eeea3bb9cd886E
          C:\Program Files\Rust stable MSVC 1.43\lib\rustlib\x86_64-pc-windows-msvc\lib\avformat.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
          C:\Program Files\Rust stable MSVC 1.43\lib\rustlib\x86_64-pc-windows-msvc\lib\avutil.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
          C:\Program Files\Rust stable MSVC 1.43\lib\rustlib\x86_64-pc-windows-msvc\lib\avcodec.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
          C:\Users\sanja\Downloads\audioserve-master\audioserve-master\target\release\deps\audioserve.exe : fatal error LNK1120: 8 unresolved externals


error: aborting due to previous error

error: could not compile `audioserve`.

To learn more, run the command again with --verbose.

@Bougakov
Copy link
Contributor Author

I've realized that I've got wrong libs (32 bit), downloaded the 64-bit version from https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.2-win64-dev.zip and placed them into C:\Program Files\Rust stable MSVC 1.43\lib\rustlib\x86_64-pc-windows-msvc\lib

C:\Users\sanja\Downloads\audioserve-master\audioserve-master>cargo build --release --no-default-features
   Compiling audioserve v0.12.1 (C:\Users\sanja\Downloads\audioserve-master\audioserve-master)
    Finished release [optimized] target(s) in 13m 19s

C:\Users\sanja\Downloads\audioserve-master\audioserve-master\target\release>audioserve.exe --version
audioserve 0.12.1

(I've compiled it on a 10-years old media PC with Atom processor and 3Gb of RAM, so ignore the "13 minutes", it is normal)

@Bougakov
Copy link
Contributor Author

Bougakov commented May 19, 2020

Got another Windows-specific bug: the program does not recognize disk labels in paths:

audioserve.exe --no-authentication t:\Audiobooks
error: Invalid value for '<BASE_DIR>...': "t" is not existing directory

I've compiled bundle.js, but it fails to load - probably, due to the error with double backslash in path (should be client/dist/bundle.js, not client/dist\\bundle.js):

C:\Users\sanja\Downloads\audioserve-master\audioserve-master\target\release>audioserve.exe --no-authentication \Audioserve\root
[2020-05-19T00:07:24Z ERROR audioserve::services::subs] Error when sending file "client/dist\\bundle.js" : The system cannot find the file specified. (os error 2)

P.S. The binary is just 4.15Mb, this looks very promising for my old file server. I really hope those bugs are minor and I would be able to use audioserve.

@Bougakov
Copy link
Contributor Author

Bougakov commented May 19, 2020

Apologies, I am a moron. I've placed the bundle.js I've compiled elsewhere (on a more powerful Mac computer) in a wrong folder. Should have placed it into audioserve-master\target\release\client\dist\bundle.js

So the only real Windows bug left to fix is the paths that contain drive letters.

I tried to make a symlink or a directory junction pointing to a T: drive where I store audiobooks collection (using either mklink /D c:\Audioserve\root t:\Audiobooks or mklink /J c:\Audioserve\root t:\Audiobooks) but that does not help. Audioserve doesn't work with such paths. Acessing http://localhost/folder/ returns HTTP error 404 instead of a JSON.

I've moved audioserve.exe to the same drive that is used to store audiobooks as a workaround.

Compiled binary: Audioserve_win64.zip

Annotation 2020-05-19 042222

@izderadicka izderadicka added bug Something isn't working help wanted Extra attention is needed windows Windows support labels May 19, 2020
@izderadicka
Copy link
Owner

Thanks for try on windows - I never did tried, my target platform was always linux. And I agree that there is couple of cross platforms bugs, which probably could be fixed.

@Bougakov
Copy link
Contributor Author

Bougakov commented May 19, 2020

One more thing: audioserve keeps the terminal window open the entire time it is being run. I believe I could use some tool like https://robotronic.de/runasserviceen.html to run it as a daemon (Windows service).

I've added the detailed description to the README in #28, please merge.

@izderadicka
Copy link
Owner

Keep just one issue #40 for windows build.
As I mentioned thanks to Docker etc. It's not much priority and will require more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed windows Windows support
Projects
None yet
Development

No branches or pull requests

2 participants