链接到头文件的头文件未找到。

时间:2010-09-08 11:24:55

标签: c gcc linker header-files

我对Nvidia的OpenCl / Cuda框架有疑问,但我认为这是一个gcc链接问题。

opencl_hello_world.c示例文件使用以下头文件:

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

opencl.h使用这些头文件:

#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>

所以所有头文件都在同一个文件夹中。

当我用gcc opencl_hello_world.c -std=c99 -lOpenCL编译时,我收到以下错误消息:

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
...

即使cl.h和其他标题文件位于此文件夹中。

搜索完SO后,我将opencl.h中的包含更改为

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

我如何阅读:gcc Can't Find a Included Header

但是搞乱框架头文件似乎不太可行了?处理这个问题的正确方法是什么?

1 个答案:

答案 0 :(得分:7)

您正在使用#include“”表单和#include&lt;&gt;,它们不会在相同的路径中搜索。 “”是您的项目的本地,并且-g命令行指定为gcc,&lt;&gt;是-I到gcc指定的“系统”路径。

您可能需要在gcc的命令行中使用-Ipath / to / includes设置包含路径。

相关问题