l1npengtul / libuvc-rs

Rust wrapper around libuvc
MIT License
48 stars 18 forks source link

compile failure: uvc_mjpeg2rgb not found #6

Closed warner closed 4 years ago

warner commented 4 years ago

Howdy.. thanks for writing this library!

I tried to write a little test program (using the vendored form of libuvc), but something failed during the compile (this is on linux, Debian "buster", with libusb-1.0.0-dev installed but not libuvc):

   Compiling uvc v0.1.6
error[E0425]: cannot find function `uvc_mjpeg2rgb` in this scope
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/frame.rs:39:39
   |
39 |                 FrameFormat::MJPEG => uvc_mjpeg2rgb(self.frame.as_ptr(), new_frame.frame.as_ptr()),
   |                                       ^^^^^^^^^^^^^ not found in this scope

error: aborting due to previous error

(I looked at the repo to see if maybe this was a change since the last released version, but there don't appear to be any git tags in the repository. Could you maybe add one for the 0.1.6 release? It looks like this repository has multiple crates in it, so I guess the tag would need to cite the package it's for, like libuvc-rs-0.1.6)

I'm not sure what the problem is.. it feels like some header file is missing a couple of function definitions.

In case it helps, my test program is just a cargo new plus the following dependency:

[dependencies]
uvc = { version = "0.1.6", default-features = false, features = ["vendor"] }

thanks! -Brian

mulimoen commented 4 years ago

Hi, seems that I've forgotten to header guard the jpg library. Jpeg should be a feature on the vendored crate, I'll see what I can do!

Thanks for the tip on tags. If I remember correctly, master corresponds to the released version.

mulimoen commented 4 years ago

@warner Would you please try the PR in #7? You should be able to add a patch section to your Cargo.toml:

[patch]
[patch.crates.io]
uvc-src = { git = "https://github.com/mulimoen/libuvc-rs.git", branch = "static-jpeg" }
warner commented 4 years ago

I added

[patch.crates-io]
uvc-src = { git = "https://github.com/mulimoen/libuvc-rs.git", branch = "static-jpeg" }

and got the same error:

   Compiling nasm-rs v0.1.7
   Compiling mozjpeg-sys v0.10.5
   Compiling uvc-src v0.1.2 (https://github.com/mulimoen/libuvc-rs.git?branch=static-jpeg#bd682d1a)
   Compiling uvc v0.1.6
error[E0425]: cannot find function `uvc_mjpeg2rgb` in this scope
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/frame.rs:39:39
   |
39 |                 FrameFormat::MJPEG => uvc_mjpeg2rgb(self.frame.as_ptr(), new_frame.frame.as_ptr()),
   |                                       ^^^^^^^^^^^^^ not found in this scope

error: aborting due to previous error

(I tried the same thing on my Mac, and the mozjpeg-sys build failed because nasm was missing.. I don't seem to have nasm on my $PATH on linux, so I'm not sure why linux got further)

mulimoen commented 4 years ago

I think the build script is not quite clever enough to pass the right jpeg library to libuvc. I will disable the nasm feature on jpeg, and we'll see how far we can get

mulimoen commented 4 years ago

@warner Lets try again!

Might have to do a cargo update to update git dependencies

warner commented 4 years ago

same thing:

   Compiling mozjpeg-sys v0.10.5
   Compiling uvc-src v0.1.2 (https://github.com/mulimoen/libuvc-rs.git?branch=static-jpeg#bec9482d)
   Compiling uvc v0.1.6
error[E0425]: cannot find function `uvc_mjpeg2rgb` in this scope
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/frame.rs:39:39
   |
39 |                 FrameFormat::MJPEG => uvc_mjpeg2rgb(self.frame.as_ptr(), new_frame.frame.as_ptr()),
   |                                       ^^^^^^^^^^^^^ not found in this scope

error: aborting due to previous error
mulimoen commented 4 years ago

Looks like I have to dive into the logs. Could you run cargo b -vvv?

warner commented 4 years ago
       Fresh libloading v0.5.2
       Fresh mozjpeg-sys v0.10.5
       Fresh clang-sys v0.29.3
       Fresh bindgen v0.54.0
       Fresh uvc-src v0.1.2 (https://github.com/mulimoen/libuvc-rs.git?branch=static-jpeg#bec9482d)
   Compiling uvc v0.1.6
     Running `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6 CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Safe and ergonomic wrapper around libuvc, allowing capture of webcam streams' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs.git' CARGO_PKG_VERSION=0.1.6 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=6 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' rustc --crate-name uvc --edition=2018 /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="uvc-src"' --cfg 'feature="vendor"' -C metadata=93d9f65f7ee65f13 -C extra-filename=-93d9f65f7ee65f13 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/deps -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern uvc_src=/home/warner/stuff/rust/control-uvc/target/debug/deps/libuvc_src-df4b40d3537996d3.rmeta --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.. -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out`
error[E0425]: cannot find function `uvc_mjpeg2rgb` in this scope
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/frame.rs:39:39
   |
39 |                 FrameFormat::MJPEG => uvc_mjpeg2rgb(self.frame.as_ptr(), new_frame.frame.as_ptr()),
   |                                       ^^^^^^^^^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
error: could not compile `uvc`.

Caused by:
  process didn't exit successfully: `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6 CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Safe and ergonomic wrapper around libuvc, allowing capture of webcam streams' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs.git' CARGO_PKG_VERSION=0.1.6 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=6 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' rustc --crate-name uvc --edition=2018 /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="uvc-src"' --cfg 'feature="vendor"' -C metadata=93d9f65f7ee65f13 -C extra-filename=-93d9f65f7ee65f13 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/deps -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern uvc_src=/home/warner/stuff/rust/control-uvc/target/debug/deps/libuvc_src-df4b40d3537996d3.rmeta --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.. -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out` (exit code: 1)
warner commented 4 years ago

(incidentally, on the mac, the uvc-sys build is currently failing because llvm-config --prefix could not be run.. I've got llvm-config on linux by installing the llvm debian package, but apparently not on the mac. I imagine most of llvm is embedded in the rust toolchain, but maybe the build script for this one needs a tool that isn't included in that set)

mulimoen commented 4 years ago

I think the llvm-config is to find and use the cmake crate, alhtough not quite suire about that.

It seems the output for compiling uvc-src is incomplete. Is there some cmake output on the highest verbosity setting?

warner commented 4 years ago

Ah, a cargo clean seems to reveal more:


   Compiling uvc-src v0.1.2 (https://github.com/mulimoen/libuvc-rs.git?branch=static-jpeg#bec9482d)
     Running `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/bec9482/uvc-src CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Vendored version of libuvc' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc-src CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs' CARGO_PKG_VERSION=0.1.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' rustc --crate-name build_script_build --edition=2018 /home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/bec9482/uvc-src/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=26de1b0bb3d47393 -C extra-filename=-26de1b0bb3d47393 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-26de1b0bb3d47393 -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern bindgen=/home/warner/stuff/rust/control-uvc/target/debug/deps/libbindgen-5874a2712f8f9149.rlib --extern cmake=/home/warner/stuff/rust/control-uvc/target/debug/deps/libcmake-b9d53b39dce19682.rlib --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/libloading-e67e8fba739623ea/out`
     Running `/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-26de1b0bb3d47393/build-script-build`
[uvc-src 0.1.2] cargo:rustc-link-lib=usb-1.0
[uvc-src 0.1.2] running: "cmake" "/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/bec9482/uvc-src/source" "-DENABLE_UVC_DEBUGGING=OFF" "-DCMAKE_BUILD_TARGET=Static" "-DBUILD_EXAMPLE=OFF" "-DJPEG_LIBRARY_RELEASE:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.." "-DJPEG_INCLUDE_DIRS:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include" "-DCMAKE_INSTALL_PREFIX=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
[uvc-src 0.1.2] -- The C compiler identification is GNU 8.3.0
[uvc-src 0.1.2] -- Check for working C compiler: /usr/bin/cc
[uvc-src 0.1.2] -- Check for working C compiler: /usr/bin/cc -- works
[uvc-src 0.1.2] -- Detecting C compiler ABI info
[uvc-src 0.1.2] -- Detecting C compiler ABI info - done
[uvc-src 0.1.2] -- Detecting C compile features
[uvc-src 0.1.2] -- Detecting C compile features - done
[uvc-src 0.1.2] -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
[uvc-src 0.1.2] -- Checking for module 'libusb-1.0'
[uvc-src 0.1.2] --   Found libusb-1.0, version 1.0.22
[uvc-src 0.1.2] -- libusb-1.0 found using pkgconfig
[uvc-src 0.1.2] -- Could NOT find JPEG (missing: JPEG_INCLUDE_DIR) 
[uvc-src 0.1.2] -- Checking for module 'libjpeg'
[uvc-src 0.1.2] --   No package 'libjpeg' found
[uvc-src 0.1.2] -- Searching library manually
[uvc-src 0.1.2] -- Could NOT find JPEG (missing: IMPORTED_JPEG_LIBRARIES IMPORTED_JPEG_INCLUDE_DIRS) 
[uvc-src 0.1.2] CMake Warning at CMakeLists.txt:51 (message):
[uvc-src 0.1.2]   JPEG not found.  libuvc will not support JPEG decoding.
[uvc-src 0.1.2] 
[uvc-src 0.1.2] 
[uvc-src 0.1.2] -- Configuring done
[uvc-src 0.1.2] -- Generating done
[uvc-src 0.1.2] CMake Warning:
[uvc-src 0.1.2]   Manually-specified variables were not used by the project:
[uvc-src 0.1.2] 
[uvc-src 0.1.2]     CMAKE_ASM_COMPILER
[uvc-src 0.1.2]     CMAKE_ASM_FLAGS
[uvc-src 0.1.2]     CMAKE_CXX_COMPILER
[uvc-src 0.1.2]     CMAKE_CXX_FLAGS
[uvc-src 0.1.2]     JPEG_INCLUDE_DIRS
[uvc-src 0.1.2] 
[uvc-src 0.1.2] 
[uvc-src 0.1.2] -- Build files have been written to: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/build
[uvc-src 0.1.2] running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
[uvc-src 0.1.2] Scanning dependencies of target uvc_static
[uvc-src 0.1.2] [ 11%] Building C object CMakeFiles/uvc_static.dir/src/ctrl.c.o
[uvc-src 0.1.2] [ 22%] Building C object CMakeFiles/uvc_static.dir/src/device.c.o
[uvc-src 0.1.2] [ 33%] Building C object CMakeFiles/uvc_static.dir/src/ctrl-gen.c.o
[uvc-src 0.1.2] [ 44%] Building C object CMakeFiles/uvc_static.dir/src/diag.c.o
[uvc-src 0.1.2] [ 55%] Building C object CMakeFiles/uvc_static.dir/src/frame.c.o
[uvc-src 0.1.2] [ 66%] Building C object CMakeFiles/uvc_static.dir/src/init.c.o
[uvc-src 0.1.2] [ 77%] Building C object CMakeFiles/uvc_static.dir/src/stream.c.o
[uvc-src 0.1.2] [ 88%] Building C object CMakeFiles/uvc_static.dir/src/misc.c.o
[uvc-src 0.1.2] [100%] Linking C static library libuvc.a
[uvc-src 0.1.2] [100%] Built target uvc_static
[uvc-src 0.1.2] Install the project...
[uvc-src 0.1.2] -- Install configuration: "Debug"
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/libuvc.a
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/include/libuvc/libuvc.h
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/include/libuvc/libuvc_config.h
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/cmake/libuvc/libuvcTargets.cmake
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/cmake/libuvc/libuvcTargets-debug.cmake
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/cmake/libuvc/FindLibUSB.cmake
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/cmake/libuvc/FindJpegPkg.cmake
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/cmake/libuvc/libuvcConfigVersion.cmake
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/pkgconfig/libuvc.pc
[uvc-src 0.1.2] -- Installing: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib/cmake/libuvc/libuvcConfig.cmake
[uvc-src 0.1.2] cargo:root=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out
[uvc-src 0.1.2] cargo:rustc-link-lib=static=mozjpeg62
[uvc-src 0.1.2] cargo:rustc-link-search=native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/..
[uvc-src 0.1.2] cargo:rustc-link-lib=static=uvc
[uvc-src 0.1.2] cargo:rustc-link-search=native=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib
     Running `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/bec9482/uvc-src CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Vendored version of libuvc' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc-src CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs' CARGO_PKG_VERSION=0.1.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' OUT_DIR=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out rustc --crate-name uvc_src --edition=2018 /home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/bec9482/uvc-src/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=df4b40d3537996d3 -C extra-filename=-df4b40d3537996d3 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/deps -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern mozjpeg_sys=/home/warner/stuff/rust/control-uvc/target/debug/deps/libmozjpeg_sys-3c309ecf9f6d7509.rlib --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.. -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib -l usb-1.0 -l static=mozjpeg62 -l static=uvc -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out`
   Compiling uvc v0.1.6
     Running `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6 CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Safe and ergonomic wrapper around libuvc, allowing capture of webcam streams' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs.git' CARGO_PKG_VERSION=0.1.6 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=6 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' rustc --crate-name uvc --edition=2018 /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="uvc-src"' --cfg 'feature="vendor"' -C metadata=93d9f65f7ee65f13 -C extra-filename=-93d9f65f7ee65f13 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/deps -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern uvc_src=/home/warner/stuff/rust/control-uvc/target/debug/deps/libuvc_src-df4b40d3537996d3.rmeta --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.. -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out`
error[E0425]: cannot find function `uvc_mjpeg2rgb` in this scope
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/frame.rs:39:39
   |
39 |                 FrameFormat::MJPEG => uvc_mjpeg2rgb(self.frame.as_ptr(), new_frame.frame.as_ptr()),
   |                                       ^^^^^^^^^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
error: could not compile `uvc`.

Caused by:
  process didn't exit successfully: `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6 CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Safe and ergonomic wrapper around libuvc, allowing capture of webcam streams' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs.git' CARGO_PKG_VERSION=0.1.6 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=6 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' rustc --crate-name uvc --edition=2018 /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/uvc-0.1.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="uvc-src"' --cfg 'feature="vendor"' -C metadata=93d9f65f7ee65f13 -C extra-filename=-93d9f65f7ee65f13 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/deps -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern uvc_src=/home/warner/stuff/rust/control-uvc/target/debug/deps/libuvc_src-df4b40d3537996d3.rmeta --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.. -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/lib -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out` (exit code: 1)
mulimoen commented 4 years ago

The problem is clearly in getting libuvc to find the jpeg we are supplying!

warner commented 4 years ago

does it maybe want IMPORTED_JPEG_INCLUDE_DIRS or JPEG_INCLUDE_DIR instead of JPEG_INCLUDE_DIRS?

mulimoen commented 4 years ago

I think IMPORTED_JPEG_INCLUDE_DIRS is an internal variable. It might be an old cmake version, so I've added the obsolete flags to the PR.

warner commented 4 years ago

Now I get:

   Compiling uvc-src v0.1.2 (https://github.com/mulimoen/libuvc-rs.git?branch=static-jpeg#cfb5520c)
     Running `CARGO=/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_MANIFEST_DIR=/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/cfb5520/uvc-src CARGO_PKG_AUTHORS='Magnus Ulimoen <flymagnus@gmail.com>' CARGO_PKG_DESCRIPTION='Vendored version of libuvc' CARGO_PKG_HOMEPAGE= CARGO_PKG_NAME=uvc-src CARGO_PKG_REPOSITORY='https://github.com/mulimoen/libuvc-rs' CARGO_PKG_VERSION=0.1.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE= LD_LIBRARY_PATH='/home/warner/stuff/rust/control-uvc/target/debug/deps:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/warner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' rustc --crate-name build_script_build --edition=2018 /home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/cfb5520/uvc-src/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=26de1b0bb3d47393 -C extra-filename=-26de1b0bb3d47393 --out-dir /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-26de1b0bb3d47393 -L dependency=/home/warner/stuff/rust/control-uvc/target/debug/deps --extern bindgen=/home/warner/stuff/rust/control-uvc/target/debug/deps/libbindgen-5874a2712f8f9149.rlib --extern cmake=/home/warner/stuff/rust/control-uvc/target/debug/deps/libcmake-b9d53b39dce19682.rlib --cap-lints warn -L native=/home/warner/stuff/rust/control-uvc/target/debug/build/libloading-e67e8fba739623ea/out`
     Running `/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-26de1b0bb3d47393/build-script-build`
[uvc-src 0.1.2] cargo:rustc-link-lib=usb-1.0
[uvc-src 0.1.2] running: "cmake" "/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/cfb5520/uvc-src/source" "-DENABLE_UVC_DEBUGGING=OFF" "-DCMAKE_BUILD_TARGET=Static" "-DBUILD_EXAMPLE=OFF" "-DJPEG_LIBRARY_RELEASE:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.." "-DJPEG_LIBRARY:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.." "-DJPEG_INCLUDE_DIRS:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include" "-DJPEG_INCLUDE_DIR:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include" "-DCMAKE_INSTALL_PREFIX=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
[uvc-src 0.1.2] -- The C compiler identification is GNU 8.3.0
[uvc-src 0.1.2] -- Check for working C compiler: /usr/bin/cc
[uvc-src 0.1.2] -- Check for working C compiler: /usr/bin/cc -- works
[uvc-src 0.1.2] -- Detecting C compiler ABI info
[uvc-src 0.1.2] -- Detecting C compiler ABI info - done
[uvc-src 0.1.2] -- Detecting C compile features
[uvc-src 0.1.2] -- Detecting C compile features - done
[uvc-src 0.1.2] -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
[uvc-src 0.1.2] -- Checking for module 'libusb-1.0'
[uvc-src 0.1.2] --   Found libusb-1.0, version 1.0.22
[uvc-src 0.1.2] -- libusb-1.0 found using pkgconfig
[uvc-src 0.1.2] -- Found JPEG: /home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/..  
[uvc-src 0.1.2] -- Found JPEG library using standard module
[uvc-src 0.1.2] -- Building libuvc with JPEG support.
[uvc-src 0.1.2] -- Configuring done
[uvc-src 0.1.2] -- Generating done
[uvc-src 0.1.2] CMake Warning:
[uvc-src 0.1.2]   Manually-specified variables were not used by the project:
[uvc-src 0.1.2] 
[uvc-src 0.1.2]     CMAKE_ASM_COMPILER
[uvc-src 0.1.2]     CMAKE_ASM_FLAGS
[uvc-src 0.1.2]     CMAKE_CXX_COMPILER
[uvc-src 0.1.2]     CMAKE_CXX_FLAGS
[uvc-src 0.1.2] 
[uvc-src 0.1.2] 
[uvc-src 0.1.2] -- Build files have been written to: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/build
[uvc-src 0.1.2] running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
[uvc-src 0.1.2] Scanning dependencies of target uvc_static
[uvc-src 0.1.2] [ 20%] Building C object CMakeFiles/uvc_static.dir/src/ctrl-gen.c.o
[uvc-src 0.1.2] [ 20%] Building C object CMakeFiles/uvc_static.dir/src/device.c.o
[uvc-src 0.1.2] [ 30%] Building C object CMakeFiles/uvc_static.dir/src/diag.c.o
[uvc-src 0.1.2] [ 40%] Building C object CMakeFiles/uvc_static.dir/src/ctrl.c.o
[uvc-src 0.1.2] [ 50%] Building C object CMakeFiles/uvc_static.dir/src/init.c.o
[uvc-src 0.1.2] [ 60%] Building C object CMakeFiles/uvc_static.dir/src/frame.c.o
[uvc-src 0.1.2] [ 70%] Building C object CMakeFiles/uvc_static.dir/src/stream.c.o
[uvc-src 0.1.2] [ 80%] Building C object CMakeFiles/uvc_static.dir/src/misc.c.o
[uvc-src 0.1.2] [ 90%] Building C object CMakeFiles/uvc_static.dir/src/frame-mjpeg.c.o
[uvc-src 0.1.2] /home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/cfb5520/uvc-src/source/src/frame-mjpeg.c:40:10: fatal error: jpeglib.h: No such file or directory
[uvc-src 0.1.2]  #include <jpeglib.h>
[uvc-src 0.1.2]           ^~~~~~~~~~~
[uvc-src 0.1.2] compilation terminated.
[uvc-src 0.1.2] make[2]: *** [CMakeFiles/uvc_static.dir/build.make:167: CMakeFiles/uvc_static.dir/src/frame-mjpeg.c.o] Error 1
[uvc-src 0.1.2] make[2]: *** Waiting for unfinished jobs....
[uvc-src 0.1.2] make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/uvc_static.dir/all] Error 2
[uvc-src 0.1.2] make: *** [Makefile:130: all] Error 2
[uvc-src 0.1.2] thread 'main' panicked at '
[uvc-src 0.1.2] command did not execute successfully, got: exit code: 2
[uvc-src 0.1.2] 
[uvc-src 0.1.2] build script failed, must exit now', /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:885:5
[uvc-src 0.1.2] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to run custom build command for `uvc-src v0.1.2 (https://github.com/mulimoen/libuvc-rs.git?branch=static-jpeg#cfb5520c)`

Caused by:
  process didn't exit successfully: `/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-26de1b0bb3d47393/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-lib=usb-1.0
running: "cmake" "/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/cfb5520/uvc-src/source" "-DENABLE_UVC_DEBUGGING=OFF" "-DCMAKE_BUILD_TARGET=Static" "-DBUILD_EXAMPLE=OFF" "-DJPEG_LIBRARY_RELEASE:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.." "-DJPEG_LIBRARY:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/.." "-DJPEG_INCLUDE_DIRS:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include" "-DJPEG_INCLUDE_DIR:PATH=/home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include" "-DCMAKE_INSTALL_PREFIX=/home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
-- The C compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
-- Checking for module 'libusb-1.0'
--   Found libusb-1.0, version 1.0.22
-- libusb-1.0 found using pkgconfig
-- Found JPEG: /home/warner/stuff/rust/control-uvc/target/debug/build/mozjpeg-sys-10574052aca5765f/out/include/..  
-- Found JPEG library using standard module
-- Building libuvc with JPEG support.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/warner/stuff/rust/control-uvc/target/debug/build/uvc-src-22e33f2401a762ee/out/build
running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
Scanning dependencies of target uvc_static
[ 20%] Building C object CMakeFiles/uvc_static.dir/src/ctrl-gen.c.o
[ 20%] Building C object CMakeFiles/uvc_static.dir/src/device.c.o
[ 30%] Building C object CMakeFiles/uvc_static.dir/src/diag.c.o
[ 40%] Building C object CMakeFiles/uvc_static.dir/src/ctrl.c.o
[ 50%] Building C object CMakeFiles/uvc_static.dir/src/init.c.o
[ 60%] Building C object CMakeFiles/uvc_static.dir/src/frame.c.o
[ 70%] Building C object CMakeFiles/uvc_static.dir/src/stream.c.o
[ 80%] Building C object CMakeFiles/uvc_static.dir/src/misc.c.o
[ 90%] Building C object CMakeFiles/uvc_static.dir/src/frame-mjpeg.c.o

--- stderr
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_ASM_COMPILER
    CMAKE_ASM_FLAGS
    CMAKE_CXX_COMPILER
    CMAKE_CXX_FLAGS

/home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/cfb5520/uvc-src/source/src/frame-mjpeg.c:40:10: fatal error: jpeglib.h: No such file or directory
 #include <jpeglib.h>
          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/uvc_static.dir/build.make:167: CMakeFiles/uvc_static.dir/src/frame-mjpeg.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/uvc_static.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.44/src/lib.rs:885:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warner commented 4 years ago

(BTW on the mac, if I use homebrew to brew install libuvc, then my test program builds normally with the features=["system"] option, so it seems that the non-vendored side is working correctly)

mulimoen commented 4 years ago

I wrongly assumed the build artifactors of mozjpeg would contain the include directories. I changed it to use the actual include directory.

warner commented 4 years ago
In file included from /home/warner/.cargo/git/checkouts/libuvc-rs-08a31db847096ccd/8e12d67/uvc-src/source/src/frame-mjpeg.c:40:
/home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/mozjpeg-sys-0.10.5/vendor/jpeglib.h:31:10: fatal error: jconfig.h: No such file or directory
 #include "jconfig.h"            /* widely used configuration options */
          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/uvc_static.dir/build.make:167: CMakeFiles/uvc_static.dir/src/frame-mjpeg.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/uvc_static.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
thread 'main' panicked at '
mulimoen commented 4 years ago

And what happens if we include both the generated binding and the include files?

warner commented 4 years ago

ooh, that succeeded (libuvc.rs.git #08a22cf4)