Header files linked to from header file not found.

江枫思渺然 提交于 2019-12-04 03:31:36

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3667184/header-files-linked-to-from-header-file-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!