How to get linker in gcc to recognize OpenCL library functions?

I urinate my feet with OpenCL. I am sure this problem is not specific to OpenCL.

the top of my main file looks like this:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <OpenCL/opencl.h>

// some code

cl_device_id device_id; //declaring a device id gives no errors

int err = clGetDeviceIDs(NULL, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
//the above API call does give an error.

I do it on Snow Leopard. I can create and run Apple examples using Xcode. I can also compile and run the NVIDIA sample code by doing make.

How to compile code without using XCODE?

+3
source share
2 answers
$ gcc -framework OpenCL hello.c

and

$ gcc -framework OpenCL hello.c

both work. Anyone want to try this in an environment without OSX?

+8
source

, Eclipse CDT. #include <OpenCL/opencl.h> #include <opencl.h> XCode -I /System/Library/Frameworks/OpenCL.framework/Headers ( - ).

0

Source: https://habr.com/ru/post/1720742/


All Articles