Hey guys,
this may be a simple question but I tried to get this code running for hours now without any feeling of success, so please help me!
I’m trying to compile a simple OpenCl program as follows:
[codebox]// standard utilities and systems includes
#include <oclUtils.h>
#include <cl_platform.h>
#include <stdio.h>
// defines, project
#define MEMCOPY_ITERATIONS 10
#define MEMSIZE_START (1<<10) //1KB
#define MEMSIZE_INCREMENT (1<<18) //256KB
#define MEMSIZE_END (1<<25) //32MB
#define CACHE_CLEAR_SIZE (1 << 24) //16 M
#define startDevice 0
#define endDevice 1
//enums, project
enum testMode { QUICK_MODE, RANGE_MODE, SHMOO_MODE };
enum memcpyKind { DEVICE_TO_HOST, HOST_TO_DEVICE, DEVICE_TO_DEVICE };
enum printMode { USER_READABLE, CSV };
enum memoryMode { PAGEABLE, PINNED };
enum accessMode { MAPPED, DIRECT };
// CL objects
cl_context cxGPUContext;
cl_command_queue cqCommandQueue;
cl_device_id *devices;
int main (void)
{
// Get OpenCL platform ID for NVIDIA if available, otherwise default
cl_platform_id clSelectedPlatformID = NULL;
cl_int ciErrNum = oclGetPlatformID (&clSelectedPlatformID);
//shrCheckError(ciErrNum, CL_SUCCESS);
// Find out how many devices there are
cl_uint ciDeviceCount;
//ciErrNum = clGetDeviceIDs (0, CL_DEVICE_TYPE_GPU, 0, NULL, &ciDeviceCount);
// Get and log the device info
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * ciDeviceCount);
printf("HELLO OPENCL\n");
return 0;
} [/codebox]
with the g++ comand:
[font=“Courier New”]g++ -I ~/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc/ -I ~/NVIDIA_GPU_Computing_SDK/shared/inc/ -L ~/NVIDIA_GPU_Computing_SDK/OpenCL/common/lib/liboclUtil.a -I ~/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc/CL test.cpp -o TEST[/font]
and I always get the error:
[font=“Courier New”]/tmp/cckXzvA0.o: In function `main’:
test.cpp:(.text+0x15): undefined reference to `oclGetPlatformID’
collect2: ld returned 1 exit status[/font]
Does anybody know what I’ve done wrong?
Greetings
running OpenSuse 11.1 x64 - g++ 4.3.2