我已按照本教程在我的计算机上安装了 fglrx 驱动程序:http://wiki.cchtml.com/index.php/Fedora_18_Installation_Guide,安装了 opencl-headers 包,最后安装了 amd app sdk 当我运行时
gcc -lOpenCL someprogram.c
我得到了错误
/usr/bin/ld: cannot find -lOpenCL
collect2: error: ld returned 1 exit status
我从 fglrxinfo 得到以下信息
display: :0 screen: 0
OpenGL vendor string: Advanced Micro Devices, Inc.
OpenGL renderer string: AMD Radeon HD 6310 Graphics
OpenGL version string: 4.2.12422 Compatibility Profile Context 13.152
并且/usr/lib64/中没有libopencl.so
我想出了如何通过运行来链接它
gcc -I/opt/AMDAPP/include -L/opt/AMDAPP/lib/x86_64 -lOpenCL hellocl.c -o hello
答案1
您需要实际的库才能ld
链接。仅编译需要标头,链接不需要。它将寻找libOpenCL.so
在您的库路径中调用的文件。从ld
联机帮助页:
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of
files to link. This option may be used any number of times. If
namespec is of the form :filename, ld will search the library path
for a file called filename, otherwise it will search the library path
for a file called libnamespec.a.
On systems which support shared libraries, ld may also search for
files other than libnamespec.a. Specifically, on ELF and SunOS
systems, ld will search a directory for a library called
libnamespec.so before searching for one called libnamespec.a.
(By convention, a ".so" extension indicates a shared library.)
Note that this behavior does not apply to :filename, which always
specifies a file called
filename.
尝试将库符号链接到构建系统正在寻找的名称。
ln -s /usr/lib64/libopencl.so /usr/lib64/libOpenCL.so