C语言 未找到从头文件链接的头文件。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3667184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 06:24:31  来源:igfitidea点击:

Header files linked to from header file not found.

cgcclinkerheader-files

提问by Framester

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

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

The opencl_hello_world.cexample file uses following header file:

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

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

with opencl.husing these header files:

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>

So all the header files are in the same folder.

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

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

当我然后编译时,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
...

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

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

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

搜索完之后,我将包含的内容更改opencl.h

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

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

我在这里阅读的方式: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?

但是弄乱框架头文件似乎不是要走的路?处理这个问题的正确方法是什么?

回答by jv42

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.

您同时使用 #include "" 形式和 #include <>,它们不会在相同的路径中搜索。"" 是您项目的本地路径,-i 命令行指定给 gcc,<> 是 -I 到 gcc 指定的“系统”路径。

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

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