io.cuh:
#ifndef IO_CUH
#define IO_CUH
#include <cuda.h>
typedef struct{
unsigned width;
unsigned height;
unsigned char *image; //RGBA
}rgb_image;
__global__ void transformToGrayKernel(rgb_image *img);
void decodeTwoSteps(const char* filename, rgb_image *img);
void encodeOneStep(const char* filename, rgb_image *img);
void processImage(const char *filename, rgb_image *img);
#endif // IO_CUH我试图使用以下makefile编译简单的程序:
lodepng.o: lodepng.h
cc -c lodepng.c -o lodepng.o
io.o: io.cuh lodepng.o
nvcc -c io.cu -o io.o
main: io.o
nvcc main.c io.o -o main“main.c”使用io.cu中的一个函数,该函数依赖于lodepng.c。
在引用代码的一些次要警告之后,我得到了以下错误:
-o主nvcc警告:不推荐使用“compute_10”和“sm_10”架构,并可能在将来的版本中删除。在main.c:1:0: io.cuh:12:12: error: expected‘=’‘,’asm‘或’属性‘之前包含在’全局 void transformToGrayKernel‘(rgb_image*img)之前的文件中;^ makefile:6:目标' main’失败的配方:*主要错误1
发布于 2015-04-25 17:37:03
这个错误是由关键词__global__引起的,而不是您内核的原型。
这是因为编译器nvcc将解释它的输入文件,并选择相应的规则来编译它。虽然您使用nvcc编译"main.c",但它将被视为C源文件,而不是CUDA源代码。因此,编译器在编译文件"main.c“时无法识别CUDA关键字__global__。
您可以将文件类型从"main.c“更改为"main.cu",并将其视为CUDA源代码。然后编译器可以识别关键字__global__。
https://stackoverflow.com/questions/29867956
复制相似问题