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

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

Open
RahulDas-dev opened this issue Jul 28, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@RahulDas-dev
Copy link

RahulDas-dev commented Jul 28, 2023

Hi ,

I was trying one of the example clinfo.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

C:\Users\rdas6\OneDrive\Desktop\codespace\rust\ocl3>cargo install --path .
  Installing ocl3 v0.1.0 (C:\Users\rdas6\OneDrive\Desktop\codespace\rust\ocl3)
    Updating crates.io index
   Compiling ocl3 v0.1.0 (C:\Users\rdas6\OneDrive\Desktop\codespace\rust\ocl3)
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\\rustcykDZWl\\symbols.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.0.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.1.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.2.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.3.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.4.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.5.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.6.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.7.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.8.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.ocl3.fa3dac1d2aa4bbe3-cgu.9.rcgu.o" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\ocl3.14ouda9ydpwkuv4x.rcgu.o" "/LIBPATH:C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps" "/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\\ocl3\\target\\release\\deps\\libopencl3-c864fcfe47dd6d5f.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\libcl3-5427efd10e859ad9.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\libopencl_sys-41e47c09cc5fd5e7.rlib" "C:\\Users\\rdas6\\OneDrive\\Desktop\\codespace\\rust\\ocl3\\target\\release\\deps\\liblibc-5c446dc1882793e3.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" "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\\ocl3\\target\\release\\deps\\ocl3.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 `ocl3` (bin "ocl3") due to previous error
error: failed to compile `ocl3 v0.1.0 (C:\Users\rdas6\OneDrive\Desktop\codespace\rust\ocl3)`, intermediate artifacts can be found at `C:\Users\rdas6\OneDrive\Desktop\codespace\rust\ocl3\target`

here is my cargo.toml

[package]
name = "ocl3"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
opencl3 = "0.8"

I am having opencl Compatiable drivers

image

+ I have downloaded the OpenCL from https://developer.nvidia.com/opencl but not sure where to place the OpenCl.lib

Rust Version

rustc 1.71.0 (8ede3aae2 2023-07-12)

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

@kenba kenba self-assigned this Jul 29, 2023
@kenba kenba added the invalid This doesn't seem right label Jul 29, 2023
@Leikoe
Copy link

Leikoe commented Sep 5, 2023

this worked for me PlasmaPower/nano-vanity#16 (comment)

@Dainerx
Copy link

Dainerx commented Nov 5, 2023

Add LIB as system env variable. It should contain the path of the OpenCL.lib you installed. For my case, on my Windows machine, LIB resolves to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\lib\x64

Btw, this issue has nothing to do with this crate.

@kenba kenba added enhancement New feature or request and removed invalid This doesn't seem right labels Dec 15, 2024
@kenba
Copy link
Owner

kenba commented Dec 15, 2024

This issue seems related to dynamic linking, see: kenba/cl3#36 and kenba/opencl-sys-rs#2.

The fix for kenba/cl3#36 was to add static and dynamic features and to make dynamic linking the default feature. I believe that this crate should incorporate the change from cl3 to fix this issue.

FYI @dmitry-zakablukov, @vmx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants