Hello,
I am new in OpenCL programming. I am trying to compile HelloWorld.cpp. I installed AMD-APP-SDK v2.8 on Ubuntu (64bits) and also on CentOS 6.4(32bits).
for both OS, after installation as I wasn't successful in compiling the code using the following command
Centos: g++ HelloWorld.cpp -I/opt/AMDAPP/include -L/opt/AMDAPP/lib/x86 -IOpenCL
Ubunta: g++ HelloWorld.cpp -I/opt/AMDAPP/include -L/opt/AMDAPP/lib/x86_64 -IOpenCL
I searched on internet and found a lot of posts
Centos:
# mkdir -p /usr/lib/OpenCL/
# cp /opt/AMDAPP/lib/x86/* /usr/lib/OpenCL/
# echo "/usr/lib/OpenCL/" > /etc/ld.so.conf.d/opencl.conf
ldconfig
Ubuntu
ln -s /opt/AMDAPP/lib/x86/libOpenCL.so /usr/lib/libOpenCL.so
ln -s /opt/AMDAPP/lib/x86/libOpenCL.so /usr/lib32/libOpenCL.so
ln -s /opt/AMDAPP/lib/x86/libOpenCL.so /usr/local/lib/libOpenCL.so
mkdir -p /usr/lib/OpenCL/
cp /opt/AMDAPP/lib/x86/* /usr/lib/OpenCL/
mkdir -p /usr/local/lib/OpenCL/
cp /opt/AMDAPP/lib/x86/* /usr/lib/OpenCL/
echo "/usr/lib/OpenCL/" > /etc/ld.so.conf.d/opencl.conf
ldconfig
but I wasn't successful
--------error message in Ubuntu
HelloWorld.cpp:32:22: fatal error: /CL/cl.h: No such file or directory
compilation terminated.
-----------error message in CentOS
/tmp/cc3Nn8ND.o: In function `main':
HelloWorld.cpp(.text+0x1f5): undefined reference to `clGetPlatformIDs'
HelloWorld.cpp(.text+0x265): undefined reference to `clGetPlatformIDs'
HelloWorld.cpp(.text+0x2bb): undefined reference to `clGetDeviceIDs'
HelloWorld.cpp(.text+0x347): undefined reference to `clGetDeviceIDs'
HelloWorld.cpp(.text+0x392): undefined reference to `clGetDeviceIDs'
HelloWorld.cpp(.text+0x3df): undefined reference to `clGetDeviceIDs'
HelloWorld.cpp(.text+0x417): undefined reference to `clCreateContext'
HelloWorld.cpp(.text+0x449): undefined reference to `clCreateCommandQueue'
HelloWorld.cpp(.text+0x4cd): undefined reference to `clCreateProgramWithSource'
HelloWorld.cpp(.text+0x505): undefined reference to `clBuildProgram'
HelloWorld.cpp(.text+0x5b3): undefined reference to `clCreateBuffer'
HelloWorld.cpp(.text+0x5ee): undefined reference to `clCreateBuffer'
HelloWorld.cpp(.text+0x60e): undefined reference to `clCreateKernel'
HelloWorld.cpp(.text+0x636): undefined reference to `clSetKernelArg'
HelloWorld.cpp(.text+0x65e): undefined reference to `clSetKernelArg'
HelloWorld.cpp(.text+0x6be): undefined reference to `clEnqueueNDRangeKernel'
HelloWorld.cpp(.text+0x70e): undefined reference to `clEnqueueReadBuffer'
HelloWorld.cpp(.text+0x774): undefined reference to `clReleaseKernel'
HelloWorld.cpp(.text+0x784): undefined reference to `clReleaseProgram'
HelloWorld.cpp(.text+0x794): undefined reference to `clReleaseMemObject'
HelloWorld.cpp(.text+0x7a4): undefined reference to `clReleaseMemObject'
HelloWorld.cpp(.text+0x7b4): undefined reference to `clReleaseCommandQueue'
HelloWorld.cpp(.text+0x7c4): undefined reference to `clReleaseContext'
collect2: ld returned 1 exit status
While in both OS I executed the same commands but I have no idea why i cannot compile this small piece of code.
I ihave installed AMD SDK in its default location /opt/AMDAPP/ and as you could see I also added symbolic link to its place. for whatever reason during compiling the code in CentOS, it cannot find the file libOpenCL where the reference to the opencl functions exist and for Ubuntu, it cannot find CL/cl.h
I appreciate any help.
Thanks,
Looks like you have forward slash at the beginning of "/CL/cl.h" include, so delete it.
seems the include path and libary path are not correctly indicated
first try to find the right include and library paths
1. locate CL/cl.h
2. locate libOpenCL
the try the command:
g++ HelloWorld.cpp -I(the include path) -L(the library path) -lOpenCL
Please note the last word is -lOpenCL not -IOpenCL
if failed, please specify your hardware platform
Thanks alot. It solved my problem.