views:

34

answers:

1

Hi everybody

I have a problem with Nvidia's OpenCl/Cuda framework, but I think it is a gcc linking issue.

The opencl_hello_world.c example file uses following header file:

#include "../OpenCL/common/inc/CL/opencl.h"

with opencl.h using these header files:

#include <../OpenCL/common/inc/CL/cl.h>
#include <../OpenCL/common/inc/CL/cl_gl.h>
#include <../OpenCL/common/inc/CL/cl_gl_ext.h>
#include <../OpenCL/common/inc/CL/cl_ext.h>

So all the header files are in the same folder.

When I then compile with gcc opencl_hello_world.c -std=c99 -lOpenCL I get following error messages:

error: ../OpenCL/common/inc/CL/cl.h: No such file or directory
error: ../OpenCL/common/inc/CL/cl_gl.h: No such file or directory
...

Even though cl.h and the other header files are located in this folder.

Having searched SO, I then changed the includes in the opencl.h to

   #include "cl.h"
   #include "cl_gl.h"

how I have read here: gcc Can't Find a Included Header.

But messing around with the frameworks header files does not seem like the way to go? What would be the proper way to handle this problem?

A: 

You're using both #include "" form and #include <>, which don't search in the same paths. "" is local to your project, and the -i command line specified to gcc, <> is the 'system' path specified by -I to gcc.

You probably need to set the include path with -Ipath/to/includes in gcc's command line.

jv42
so I add `-I../OpenCL/common/inc/CL/` but I still get the error: `.../OpenCL/common/inc/CL/cl.h: No such file or directory`
Framester
Since the path is already in the #include <>, you should pass to -I the path BEFORE ../OpenCL/etc, not after.
jv42
Hi jv42, thank you for the tipp: I tried `gcc opencl_hello_world.c -I/home/myuseraccount/Documents/projects/opencl/NVIDIA_GPU_Computing_SDK -L/usr/local/cuda/lib -lOpenCL`, but the error is still: `../OpenCL/common/inc/CL/cl.h: No such file or directory`. I think, I overlooked something stupid.
Framester
Are you sure about the include path? Don't forget it starts with ".." in the NV code...
jv42