Problem with the compilation of Cuda source

Hello,

I’ve some problems to compile a CUDA code. I think I’ve done all the things that must be done to compile CUDA code, but I still got errors. Can someone help me please ?

Here is what I do :

1° Update of the environment variable :
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/gcc/x86_64-linux-gnu/4.4.1/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib32/gcc/i486-linux-gnu/4.4.1

2° I include the usefull headers in my file :
#include <cuda.h>
#include <cutil.h>
#include <cutil_inline.h>

3° I link the library and I include the folders in the makefile :
all: main

main: comptage.o distinct.cuo
nvcc -o main bin/distinct.cuo bin/comptage.o -lcuda -L /usr/local/cuda/lib64

distinct.cuo : distinct.cu
nvcc -c distinct.cu -o bin/distinct.cuo -I /usr/include/cuda -I /usr/local/cuda/include -I /usr/local/cuda/lib64/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/shared/inc/ -lcudart -lcuda

comptage.o: comptage.c
nvcc -o bin/comptage.o -c comptage.c -I /usr/include/cuda -I /usr/local/cuda/include -I /usr/local/cuda/lib64/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/shared/inc/ -lcudart -lcuda

When I compile, I got these errors when nvcc tries to compile the “.c” file (the first one to be compiled) :

comptage.c: In function ‘main’:
comptage.c:57: error: ‘cudaMemcpyHostToDevice’ undeclared (first use in this function)
comptage.c:57: error: (Each undeclared identifier is reported only once
comptage.c:57: error: for each function it appears in.)
comptage.c:61: error: ‘cudaMemcpyDeviceToHost’ undeclared (first use in this function)
==> when I compile without the include of the header cutil_inline

In file included from comptage.c:6:
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h:118: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cutReadFilef’
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cutReadFiled’
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h:150: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cutReadFilei’
… (more errors of the same kind)

In file included from /home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline.h:20,
from comptage.c:7:
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h: In function ‘cutGetMaxGflopsDeviceId’:
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: ‘cudaDeviceProp’ undeclared (first use in this function)
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: (Each undeclared identifier is reported only once
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: for each function it appears in.)
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: expected ‘;’ before ‘deviceProp’
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:106: error: ‘deviceProp’ undeclared (first use in this function)
… (more errors of the same kind)

==> when I compile with the include of the header cutil_inline

I don’t know what I can do to fix the problem.

Thanks for your help !!

Hello,

I’ve some problems to compile a CUDA code. I think I’ve done all the things that must be done to compile CUDA code, but I still got errors. Can someone help me please ?

Here is what I do :

1° Update of the environment variable :
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/gcc/x86_64-linux-gnu/4.4.1/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib32/gcc/i486-linux-gnu/4.4.1

2° I include the usefull headers in my file :
#include <cuda.h>
#include <cutil.h>
#include <cutil_inline.h>

3° I link the library and I include the folders in the makefile :
all: main

main: comptage.o distinct.cuo
nvcc -o main bin/distinct.cuo bin/comptage.o -lcuda -L /usr/local/cuda/lib64

distinct.cuo : distinct.cu
nvcc -c distinct.cu -o bin/distinct.cuo -I /usr/include/cuda -I /usr/local/cuda/include -I /usr/local/cuda/lib64/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/shared/inc/ -lcudart -lcuda

comptage.o: comptage.c
nvcc -o bin/comptage.o -c comptage.c -I /usr/include/cuda -I /usr/local/cuda/include -I /usr/local/cuda/lib64/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/ -I /home/sebastien/NVIDIA_GPU_Computing_SDK/shared/inc/ -lcudart -lcuda

When I compile, I got these errors when nvcc tries to compile the “.c” file (the first one to be compiled) :

comptage.c: In function ‘main’:
comptage.c:57: error: ‘cudaMemcpyHostToDevice’ undeclared (first use in this function)
comptage.c:57: error: (Each undeclared identifier is reported only once
comptage.c:57: error: for each function it appears in.)
comptage.c:61: error: ‘cudaMemcpyDeviceToHost’ undeclared (first use in this function)
==> when I compile without the include of the header cutil_inline

In file included from comptage.c:6:
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h:118: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cutReadFilef’
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cutReadFiled’
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h:150: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cutReadFilei’
… (more errors of the same kind)

In file included from /home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline.h:20,
from comptage.c:7:
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h: In function ‘cutGetMaxGflopsDeviceId’:
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: ‘cudaDeviceProp’ undeclared (first use in this function)
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: (Each undeclared identifier is reported only once
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: for each function it appears in.)
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:101: error: expected ‘;’ before ‘deviceProp’
/home/sebastien/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil_inline_runtime.h:106: error: ‘deviceProp’ undeclared (first use in this function)
… (more errors of the same kind)

==> when I compile with the include of the header cutil_inline

I don’t know what I can do to fix the problem.

Thanks for your help !!