0

我正在尝试在 mingw32 中使用以下命令编译我的 OpenCL 应用程序:mingw32-gcc -o plat plat.c

但我收到此错误:CL/cl.h 没有这样的文件或目录

我在网上和这个网站上搜索了很多次,但找不到任何好的答案。我做了所有的工作,但它仍然出错。我使用 AMD Radeon HD 5470 并在 win 7 上安装了最新的催化剂驱动程序和 AMD APP SDK 2.8 我安装了 VS 2012

在我的代码中,我使用了几个希望工作的状态,但是....它仍然会犯同样的错误

我还在编译命令中使用了 -I & -L ,它仍然会出错:CL/cl.h no such file or directory

我怎么不知道如何使用make 文件来编译代码

我会非常感谢任何帮助我的人:mehdioraki59@yahoo.com

我的系统是:dell studio 1558

这是我非常非常简单的测试代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef MAC
#include <OpenCL/cl.h>
#else
#include <C:\Program Files (x86)\AMD APP\include\CL\cl.hpp>
//#include <CL/cl.h>    >>>>>>>  i manually disabled this line but there is still error
#endif
int main() {
cl_platform_id             *platforms;
cl_uint                    num_platforms;
cl_int                     i, err, platform_index = -1;
char*                      ext_data;
size_t                     ext_size;
err = clGetPlatformIDs(1, NULL, &num_platforms);
if(err < 0) {
perror("Couldn't find any platforms.");
exit(1);
}
free(platforms);
return 0;
}
4

2 回答 2

0

我终于找到了答案,也谢谢chippies先生:您的建议如何帮助我更多我使用了这个make文件:PROJ=qwerty_mehdi CC=mingw32-gcc CFLAGS=-Wall LIB=-lOpenCL ifdef AMDAPPSDKROOT INC_DIRS="$(AMDAPPSDKROOT)include " LIB_DIRS="$(AMDAPPSDKROOT)lib\x86" else ifdef NVSDKCOMPUTE_ROOT INC_DIRS="$(NVSDKCOMPUTE_ROOT)\OpenCL\common\inc" LIB_DIRS="$(NVSDKCOMPUTE_ROOT)\OpenCL\common\lib\Win32" endif endif $(PROJ ): qwerty.c $(CC) $(CFLAGS) -o $@ $^ -I$(INC_DIRS) -L$(LIB_DIRS) $(LIB)

并删除了这一行:#include

在此之后.exe成功制作

在 make 文件代码行中,qwerty.c 是我之前解释过的代码。

于 2013-06-20T16:12:22.447 回答
0

您需要将 -I"C:\Program Files (x86)\AMD APP\include" 添加到您的构建命令中,以告诉 mingw32-gcc 在哪里可以找到 CL/cl.h。使用它,#include 行应该可以正常工作。

于 2013-06-17T16:21:01.317 回答