Command make failed with error like “ld cannot find l" .

Detail messages are like below

/usr/bin/ld: cannot find -lOpenCL
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:20: DeviceInfo] Error 1


gcc or g++ cannot find -l<nameOfTheLibrary>, it means that the compiler looked for the file lib{nameOfTheLibrary}.so, but it couldn’t find it in the shared library search path, which by default points to /lib and /usr/lib and the path included by /etc/ . Or if you have environment variable LD_LIBRARY_PATH set , the directories listed will be the search path.


The solution is to make a symbolic link for the library to a known library location ,for example:

sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/

Alternatively , you can also use env variable LD_LIBRARY_PATH to archive this , or edit /etc/ then run command ldconfig to update your library path.

wait , but how do I know where is the library file

You can use command locate or find to get the location of the so file ,eg:

root@ubuntu:/home/j/Desktop# locate
root@ubuntu:/home/j/Desktop# find / -name '*'
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied

In case you can find it ,then you need to install it .