Framester
Framester

Reputation: 35551

Header files linked to from header file not found.

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?

Upvotes: 8

Views: 37182

Answers (1)

jv42
jv42

Reputation: 8593

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.

Upvotes: 12

Related Questions