Twinklebear / oidn-rs

Rust bindings to Intel's OpenImageDenoise Library
MIT License
24 stars 12 forks source link

Cannot find -lOpenImageDenoise in simple example #1

Closed mandeep closed 4 years ago

mandeep commented 4 years ago

I used the Linux portion of the .travis.yml file to set up oidn-rs locally. Running cargo build in the oidn-rs root directory works without a hitch. However, once I run cargo build inside the examples/simple directory I receive the error below. This is on the rust nightly channel.

 ⚙ mandeep@debian  ~/Github/oidn-rs/examples/simple   master  cargo build          
   Compiling simple v0.1.0 (/home/mandeep/Github/oidn-rs/examples/simple)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.10e7scvkjo5xr1qs.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.1114xk03wuygadnt.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.198yv0457ytazasw.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.1fugcnd0ijovw8mx.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.1qnh2ty08bbosrk2.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.1uo5jry6g70u6z9y.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.202y95m9re7oisz1.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.25rzgb1pj54ffltw.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.27np1ays1d7giu1r.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.2cgu16h5p89l4i0p.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.2df0nagjwpruk2o9.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.2eteoququ16rinli.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.2k870od7zn1q6iw0.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.2nsdq68iuhlbc87f.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.2ubk16nxo7usno2g.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.35shkri2xml7uhoz.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.3gjl4z5l0zakoxp0.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.3gjz7uzy3hyevg2r.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.3i4p15ennogg71tp.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.3leejhehohqrktp6.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.3trsr4dgnjphsd39.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.3ycwm507kte7x7qv.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.44savxfetm6ynkaw.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.496g3quthpya52q1.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.4y8o9i8zf2m70y35.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.4z3w90ewqi6mjfu8.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.56lmlb35ajbq2368.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.59jeob5c333kewex.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.6swc7btmzhciro1.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.7lz2ce9yo5g9417.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.a5orbdhr9mw6a69.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.fln42mev320ldt1.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.j9zh3nn0ndwwlsd.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.rvmv4myesj7vdqq.rcgu.o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.svj5hvu23e0s1jk.rcgu.o" "-o" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/simple-555ea0c273ffc096.1p7xa2aj0pjn20k0.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps" "-L" "/home/mandeep/Github/oidn-rs/oidn-0.9.0.x86_64.linux/lib" "-L" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libimage-19c8bfc0a093218b.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libtiff-1dbdaff8f912ea6a.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libpng-4eee21f29187569d.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libdeflate-ab30818ebc4ce7c6.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libinflate-d1c8eb87c826883a.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libadler32-ad5b599d96e3ff5e.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libbitflags-9ff4af2eea6b7f62.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libjpeg_decoder-9a18c751f1dcba32.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/librayon-666094927f8be6e1.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/librayon_core-f25062e4e349b0fd.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libnum_cpus-8fd4f8fbad193ee9.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/liblibc-7e4b350984e288d7.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libcrossbeam_queue-2c4a7f2f5940315b.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libeither-e8beca7025a95652.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libcrossbeam_deque-6e0ca620018d5b60.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libcrossbeam_epoch-b2c3719cb68954d4.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libscopeguard-e761060731cb9561.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libmemoffset-ec3c10ec604430fc.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libcrossbeam_utils-0e034e5687f3e452.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/liblazy_static-dea2c311d7cdf8f6.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libarrayvec-5a0090849a80d1e6.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libcfg_if-6bdbb326b27096b5.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libgif-0d45034308429732.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libcolor_quant-0ea9d7fcc0ca401b.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libscoped_threadpool-470f3dd0a0de4762.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libnum_rational-32da72c7da87cac0.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libnum_iter-a33e07d0bf371ee4.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libnum_integer-29cc3d4e4339af9a.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libnum_traits-7e423cfa39541bdd.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/liblzw-3de8f17e4053b664.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/libbyteorder-29d135459c74bdc9.rlib" "/home/mandeep/Github/oidn-rs/examples/simple/target/debug/deps/liboidn-f4e51f7275d91437.rlib" "-Wl,--start-group" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-623a6dc23f9cb558.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-862860ba17d4a376.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-84d204dc20d28a21.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-d7f4a94756d90f61.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-74425e3f3d79d417.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-6ea6570cade36603.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-cd8fc47e9b83cca0.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-58ae00f8c1022396.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-dbc21f93cc0a5b29.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-04b52238d74659b4.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-d00e044b91e465a0.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-4fd884ff5e34b6c0.rlib" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-437fd3003e58c8ca.rlib" "-Wl,--end-group" "/home/mandeep/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-78f8338ee0fc4c22.rlib" "-Wl,-Bdynamic" "-lutil" "-lutil" "-lOpenImageDenoise" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/bin/ld: cannot find -lOpenImageDenoise
          collect2: error: ld returned 1 exit status
mandeep commented 4 years ago

I was able to solve this by fiddling with /usr/local/lib and LD_LIBRARY_PATH, but I'm not sure this is the preferred solution.

Twinklebear commented 4 years ago

Thanks for the bug report! It shouldn't be necessary to set LD_LIBRARY_PATH at build time (maybe at runtime). At build time I use the OIDN_DIR env. var to find the library, and it looks like that is set correctly in the log from cargo, so I'm not sure why it fails to find it.

I'll get CI running nightly as well and take a lookt

mandeep commented 4 years ago

It looks like the nightly build passed, and I'm unable to replicate this again so I think it's safe to close this issue.

One thing I was wondering however, is if it's possible to pass ODIN_DIR at runtime rather than build time.

Twinklebear commented 4 years ago

Since we need it to link the library in our build.rs build script, we need the OIDN_DIR at build time. Do you mean more of specifying a library path to find the OIDN DLLs or SO files?

mandeep commented 4 years ago

I'm using oidn-rs as a crate in my project and I'm trying to emulate the oidn-rs travis build in my build.rs. I keep running into a problem with OIDN_DIR not being set and I think it's related to this issue: https://github.com/rust-lang/cargo/issues/4121. I'm hoping to find a workaround but I'm not sure one exists at the application level.

Twinklebear commented 4 years ago

That could be the issue you're having as well, where the OIDN_DIR var is not propagated down to the crate, but if you set it as a global environment variable it seems like it should find it? I'm not sure how the env-var query works, but something like export OIDN_DIR=<path> will be picked up from the environment. For example, the example in this crate doesn't have a build script but just uses the oidn-rs one to find OIDN_DIR.

I was looking for your build script in your repo but couldn't find it, how were you trying to pass the OIDN_DIR var over to oidn-rs? Propagating it through the build script may not work due to that issue, but setting it globally in the environment should.

mandeep commented 4 years ago

Right now I'm using export OIDN_DIR=path and also appending to LD_LIBRARY_PATH. However, I feel like this isn't very portable and would prefer to have this set in a build.rs build script. It seems that Cargo build scripts right now don't really have the capability of exporting environment variables for dependencies at compile time.