meh / rust-ffmpeg-sys

moved to meh/rust-ffmpeg
145 stars 87 forks source link

Cross compile from linux to windows #103

Open wojtess opened 1 year ago

wojtess commented 1 year ago

Host OS: Ubuntu Target OS: Windows 10

command: $ RUST_BACKTRACE=1 PKG_CONFIG_ALLOW_CROSS=1 cargo build --target x86_64-pc-windows-gnu

Log:

error: failed to run custom build command for `ffmpeg-sys v4.3.3`

Caused by:
  process didn't exit successfully: `/home/wojtess/Documents/rust/qbox/target/debug/build/ffmpeg-sys-7fbc21dc22bdcd9e/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-link-search=native=/home/wojtess/Documents/rust/qbox/target/x86_64-pc-windows-gnu/debug/build/ffmpeg-sys-08f8dafae26dcfed/out/dist/lib
  cargo:rustc-link-lib=static=avcodec
  cargo:rustc-link-lib=static=avdevice
  cargo:rustc-link-lib=static=avfilter
  cargo:rustc-link-lib=static=avformat
  cargo:rustc-link-lib=static=avutil
  cargo:rustc-link-lib=static=swresample
  cargo:rustc-link-lib=static=swscale
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-pc-windows-gnu")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-gnu
  CC_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_gnu
  CC_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-gnu
  CFLAGS_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_gnu
  CFLAGS_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,llvm14-builtins-abi,sse,sse2")
  configure: Unknown OS 'windows'.

  If you think configure made a mistake, make sure you are using the latest
  version from Git.  If the latest version fails, report the problem to the
  ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
  Include the log file "ffbuild/config.log" produced by configure as this will help
  solve the problem.

  --- stderr
  Using stack size: Ok(3145728)
  Cloning into 'ffmpeg-4.3'...
  thread 'ffmpg-sys-build' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "configure failed " }', /home/wojtess/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-4.3.3/build.rs:644:21
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::unwrap
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1113:23
     4: build_script_build::thread_main
               at ./build.rs:644:13
     5: core::ops::function::FnOnce::call_once
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:251:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', /home/wojtess/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-4.3.3/build.rs:629:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::unwrap
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1113:23
     4: build_script_build::main
               at ./build.rs:623:5
     5: core::ops::function::FnOnce::call_once
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:251:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
wojtess commented 1 year ago

After some trying I have this errors now.

command: RUST_BACKTRACE=1 PKG_CONFIG_ALLOW_CROSS=1 cargo build --target x86_64-pc-windows-gnu log:

[...]
cargo:rustc-cfg=feature="avcodec_version_greater_than_58_104"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_105"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_106"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_107"
  cargo:rustc-cfg=feature="ffmpeg_3_0"
  cargo:ffmpeg_3_0=true
  cargo:rustc-cfg=feature="ffmpeg_3_1"
  cargo:ffmpeg_3_1=true
  cargo:rustc-cfg=feature="ffmpeg_3_2"
  cargo:ffmpeg_3_2=true
  cargo:rustc-cfg=feature="ffmpeg_3_3"
  cargo:ffmpeg_3_3=true
  cargo:rustc-cfg=feature="ffmpeg_3_1"
  cargo:ffmpeg_3_1=true
  cargo:rustc-cfg=feature="ffmpeg_4_0"
  cargo:ffmpeg_4_0=true
  cargo:rustc-cfg=feature="ffmpeg_4_1"
  cargo:ffmpeg_4_1=true
  cargo:rustc-cfg=feature="ffmpeg_4_2"
  cargo:ffmpeg_4_2=true
  cargo:rustc-cfg=feature="ffmpeg_4_3"
  cargo:ffmpeg_4_3=true

  --- stderr
  Using stack size: Ok(3145728)
  /usr/include/x86_64-linux-gnu/bits/types/time_t.h:10:18: error: typedef redefinition with different types ('__time_t' (aka 'long') vs '__time64_t' (aka 'long long'))
  /usr/x86_64-w64-mingw32/include/corecrt.h:143:20: note: previous definition is here
  /usr/include/x86_64-linux-gnu/bits/types/time_t.h:10:18: error: typedef redefinition with different types ('__time_t' (aka 'long') vs '__time64_t' (aka 'long long')), err: true
  thread 'ffmpg-sys-build' panicked at 'Unable to generate bindings: ()', /home/wojtess/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-4.3.3/build.rs:1279:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::expect
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1070:23
     4: build_script_build::thread_main
               at ./build.rs:1276:24
     5: core::ops::function::FnOnce::call_once
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:251:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', /home/wojtess/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-4.3.3/build.rs:629:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::unwrap
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1113:23
     4: build_script_build::main
               at ./build.rs:623:5
     5: core::ops::function::FnOnce::call_once
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:251:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace

I am also trying to build using other target

command: RUST_BACKTRACE=1 PKG_CONFIG_ALLOW_CROSS=1 cargo build --target x86_64-pc-windows-msvc log:

[...]
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_103"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_104"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_105"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_106"
  cargo:rustc-cfg=feature="avcodec_version_greater_than_58_107"
  cargo:rustc-cfg=feature="ffmpeg_3_0"
  cargo:ffmpeg_3_0=true
  cargo:rustc-cfg=feature="ffmpeg_3_1"
  cargo:ffmpeg_3_1=true
  cargo:rustc-cfg=feature="ffmpeg_3_2"
  cargo:ffmpeg_3_2=true
  cargo:rustc-cfg=feature="ffmpeg_3_3"
  cargo:ffmpeg_3_3=true
  cargo:rustc-cfg=feature="ffmpeg_3_1"
  cargo:ffmpeg_3_1=true
  cargo:rustc-cfg=feature="ffmpeg_4_0"
  cargo:ffmpeg_4_0=true
  cargo:rustc-cfg=feature="ffmpeg_4_1"
  cargo:ffmpeg_4_1=true
  cargo:rustc-cfg=feature="ffmpeg_4_2"
  cargo:ffmpeg_4_2=true
  cargo:rustc-cfg=feature="ffmpeg_4_3"
  cargo:ffmpeg_4_3=true

  --- stderr
  Using stack size: Ok(3145728)
  /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:30:10: fatal error: 'errno.h' file not found
  /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:30:10: fatal error: 'errno.h' file not found, err: true
  thread 'ffmpg-sys-build' panicked at 'Unable to generate bindings: ()', /home/wojtess/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-4.3.3/build.rs:1279:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::expect
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1070:23
     4: build_script_build::thread_main
               at ./build.rs:1276:24
     5: core::ops::function::FnOnce::call_once
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:251:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', /home/wojtess/.cargo/registry/src/github.com-1ecc6299db9ec823/ffmpeg-sys-4.3.3/build.rs:629:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::unwrap
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/result.rs:1113:23
     4: build_script_build::main
               at ./build.rs:623:5
     5: core::ops::function::FnOnce::call_once
               at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:251:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
kornelski commented 1 year ago

Are you able to build it without the crate?

wojtess commented 1 year ago

Yes, but only using command RUST_BACKTRACE=1 PKG_CONFIG_ALLOW_CROSS=1 cargo build --target x86_64-pc-windows-gnu. x86_64-pc-windows-msvc target dont work.

kornelski commented 1 year ago

That's normal. The MSVC target is for the Microsoft Visual Studio compiler, which you're unlikely to have installed on Linux.

wojtess commented 1 year ago

This make sense, but still I cant compile from linux to windows using x86_64-pc-windows-gnu target.