Я пытаюсь скомпилировать программу openCL в Ubuntu с помощью карты NVIDIA, которая когда-то работала раньше,
#include <CL/cl.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cl_platform_id platform;
cl_device_id device;
cl_context context;
cl_command_queue command_queue;
cl_int error;
if(clGetPlatformIDs(1, &platform, NULL) != CL_SUCCESS) {
cout << "platform error" << endl;
}
if(clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL) != CL_SUCCESS) {
cout << "device error" << endl;
}
context = clCreateContext(NULL, 1, &device, NULL, NULL, &error);
if(error != CL_SUCCESS) {
cout << "context error" << endl;
}
command_queue = clCreateCommandQueue(context, device, 0, &error);
if(error != CL_SUCCESS) {
cout << "command queue error" << endl;
}
return 0;
}
Я скомпилирую ее так,
g++ -I/usr/local/cuda/include -L/usr/lib/nvidia-current -lOpenCL opencl.cpp
и получаюэтот результат
/tmp/ccAdS9ig.o: In function `main':
opencl.cpp:(.text+0x1a): undefined reference to `clGetPlatformIDs'
opencl.cpp:(.text+0x3d): undefined reference to `clGetDeviceIDs'
opencl.cpp:(.text+0x65): undefined reference to `clCreateContext'
opencl.cpp:(.text+0x85): undefined reference to `clCreateCommandQueue'
collect2: ld returned 1 exit status
, но nm -D /usr/lib/nvidia-current/libOpenCL.so
говорит мне, что libOpenCL.so хотя бы содержит clGetPlatformIDs
0000000000002400 T clGetKernelWorkGroupInfo
0000000000002140 T clGetMemObjectInfo
0000000000002e80 T clGetPlatformIDs
0000000000002de0 T clGetPlatformInfo
0000000000002310 T clGetProgramBuildInfo
00000000000022f0 T clGetProgramInfo
00000000000021f0 T clGetSamplerInfo
Я что-то упустил.