cogciprocate / ocl

OpenCL for Rust
Other
731 stars 75 forks source link

How to resolve "fatal error LNK1181: cannot open input file 'OpenCL.lib'" #223

Closed RahulDas-dev closed 1 year ago

RahulDas-dev commented 1 year ago

I was trying one of the example examples/trivial.rs on my windows 11 , But I am having this error = note: LINK : fatal error LNK1181: cannot open input file 'OpenCL.lib'

Here is the full error stack

cargo install --path .

  Installing opencl_exapmples v0.1.0 (C:\Users\rdas6\OneDrive\Desktop\codespace\rust\opencl_exapmples)
    Updating crates.io index
   Compiling autocfg v1.1.0
   Compiling crossbeam-utils v0.8.16
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling semver v1.0.18
   Compiling scopeguard v1.2.0
   Compiling libc v0.2.147
   Compiling crossbeam-queue v0.3.8
   Compiling thiserror v1.0.44
   Compiling cl-sys v0.4.2
   Compiling bitflags v1.3.2
   Compiling futures v0.1.31
   Compiling nodrop v0.1.14
   Compiling num-traits v0.2.16
   Compiling memoffset v0.9.0
   Compiling crossbeam-epoch v0.9.15
   Compiling rustc_version v0.4.0
   Compiling crossbeam-channel v0.5.8
   Compiling quote v1.0.32
   Compiling ocl-core v0.11.3
   Compiling syn v2.0.27
   Compiling crossbeam-deque v0.8.3
   Compiling crossbeam v0.8.2
   Compiling num-traits v0.1.43
   Compiling ocl-core-vector v0.1.1
   Compiling num-complex v0.4.3
   Compiling qutex v0.2.4
   Compiling enum_primitive v0.1.1
   Compiling thiserror-impl v1.0.44
   Compiling ocl v0.19.4
   Compiling opencl_exapmples v0.1.0 (C:\Users\rdas6\OneDrive\Desktop\codespace\rust\opencl_exapmples)
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\rdas6\\AppData\\Local\\Temp\\rustcSu0V44\\symbols.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.0.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.1.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.10.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.11.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.12.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.13.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.14.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.15.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.2.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.3.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.4.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.5.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.6.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.7.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.8.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.opencl_exapmples.965552d88352c582-cgu.9.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.48m137ye9xgwzt0h.rcgu.o" "/LIBPATH:C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps" "/LIBPATH:C:\\Program Files (x86)\\OCL_SDK_Light\\lib\\x86_64" "/LIBPATH:C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libocl-be1b88f185bce68b.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libqutex-17315bc301b3cc6b.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcrossbeam-c88ff397d376d61c.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcrossbeam_channel-d045d38bfb118900.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcrossbeam_deque-76ea64de084ee30c.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcrossbeam_queue-a6501f559657659d.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcrossbeam_epoch-c55fa9c67e85a73c.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libmemoffset-b55c8ba0f7fb3e9e.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libscopeguard-43698d9c3affcca8.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcrossbeam_utils-a57e32064ed9e037.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcfg_if-bc2aedd5c79370af.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libnodrop-18520295fba483b4.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libocl_core-d5f30712f498e2e7.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libthiserror-a484fc75d4ca9f7e.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libcl_sys-56ff81051325f1a8.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\liblibc-5c446dc1882793e3.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libocl_core_vector-e2f3015fba4ae840.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libnum_complex-0c4b53a7d96d6ea4.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libenum_primitive-f474236c15cc624f.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libnum_traits-3755e5c67c128f29.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libbitflags-bd7ff5bcf362b03a.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libfutures-61b561805b301580.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\libnum_traits-43c5b6865e9f72b1.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-f54c5a8dc7e7febf.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-92f7800729779464.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-6da5127b1b379d8e.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-efa74c8d8702db5b.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-e9ed0b4fbfe1d158.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-23c6870c75efea7d.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libminiz_oxide-19857ab63c6bf99c.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libadler-0d8b8ed2a2fb22e9.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-3a3d97b2ce691588.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-60ba5e33f92355d7.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-94c0a2e24d7696be.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-edd8efb6a2cb3252.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-cb8dd18d30da7a99.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-75c0b134deed8bd9.rlib" "C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-96d2ffc8ffc7b9b5.rlib" "OpenCL.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\opencl_exapmples\\target\\release\\deps\\opencl_exapmples.exe" "/OPT:REF,ICF" "/DEBUG" "/NATVIS:C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\rdas6\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : fatal error LNK1181: cannot open input file 'OpenCL.lib'

error: could not compile `opencl_exapmples` (bin "opencl_exapmples") due to previous error
error: failed to compile `opencl_exapmples v0.1.0 (C:\Users\rdas6\OneDrive\Desktop\codespace\rust\opencl_exapmples)`, intermediate artifacts can be found at `C:\Users\rdas6\OneDrive\Desktop\codespace\rust\opencl_exapmples\target`

here is my repo

I am having opencl Compatible drivers

opencl_driver

My Rust Version

rustc 1.71.0 (8ede3aae2 2023-07-12)

Any assistance or insights on resolving this issue would be greatly appreciated. Thank you!

Dantsz commented 1 year ago

The linking error says you're missing the opencl .lib file to link against, the .dll in the screenshot is used at runtime. I had the same problem on my windows 10 machine, I had to install the CUDA toolkit to get the library, but that's because I have an Nvidia GPU, not sure what the alternative in your case is.

c0gent commented 1 year ago

If you're still stuck, try the following quick and dirty method. This is for Windows but Linux follows the same principle. I'm including generic instructions for non-intel users as well.

Haven't tested this on AMD recently but should work.