cudaDeviceProp undeclared (first use in this function)
hi, i have some problems when i try compile a program that uses this function.
i have a .cu file where i have one function that use the function and another file .c where i call the .cu function.

[code]nvcc -o projecto.o -c -arch=sm_11 -O3 -I. projecto.cu[/code]

[code]gcc main.c `pkg-config libglade-2.0 gtk+-2.0 --cflags` `pkg-config libglade-2.0 gtk+-2.0 --libs` -Wl,-export-dynamic projecto.o -I/usr/local/cuda/include -I/home/pinto/NVIDIA_CUDA_SDK/common/inc -L/usr/local/cuda/lib -L/home/pinto/NVIDIA_CUDA_SDK/lib -L/home/pinto/NVIDIA_CUDA_SDK/common/lib -lcuda -lcudart -lcutil -lm -lmpich[/code]

ERROR:
[code]projecto.cu: In function âgpu_infoâ:
projecto.cu:44: error: âcudaDevicePropâ undeclared (first use in this function)
projecto.cu:44: error: (Each undeclared identifier is reported only once
projecto.cu:44: error: for each function it appears in.)
projecto.cu:44: error: expected â;â before âdevicePropâ[/code]

LINE 44:
[code]cudaDeviceProp deviceProp;[/code]
hi, i have some problems when i try compile a program that uses this function.

i have a .cu file where i have one function that use the function and another file .c where i call the .cu function.



nvcc -o projecto.o -c -arch=sm_11 -O3 -I. projecto.cu




gcc main.c `pkg-config libglade-2.0 gtk+-2.0 --cflags` `pkg-config libglade-2.0 gtk+-2.0 --libs` -Wl,-export-dynamic projecto.o -I/usr/local/cuda/include -I/home/pinto/NVIDIA_CUDA_SDK/common/inc -L/usr/local/cuda/lib -L/home/pinto/NVIDIA_CUDA_SDK/lib -L/home/pinto/NVIDIA_CUDA_SDK/common/lib -lcuda -lcudart -lcutil -lm -lmpich




ERROR:

projecto.cu: In function âgpu_infoâ:

projecto.cu:44: error: âcudaDevicePropâ undeclared (first use in this function)

projecto.cu:44: error: (Each undeclared identifier is reported only once

projecto.cu:44: error: for each function it appears in.)

projecto.cu:44: error: expected â;â before âdevicePropâ




LINE 44:

cudaDeviceProp deviceProp;

#1
Posted 07/06/2009 12:34 PM   
Did you include the correct headers?

#include <cuda.h>
#include <cuda_runtime_api.h>

N.
Did you include the correct headers?



#include <cuda.h>

#include <cuda_runtime_api.h>



N.

#2
Posted 07/06/2009 12:49 PM   
yes, i include in both

projecto.cu
[code]#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <cuda.h>
#include <cuda_runtime_api.h>[/code]

main.c
[code]#include <gtk/gtk.h>
#include <glade/glade.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

#include <cuda.h>
#include <cuda_runtime_api.h>

#include "projecto.cu"[/code]
yes, i include in both



projecto.cu

#include <stdio.h>

#include <string.h>

#include <stdlib.h>



#include <cuda.h>

#include <cuda_runtime_api.h>




main.c

#include <gtk/gtk.h>

#include <glade/glade.h>



#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <time.h>

#include <math.h>



#include <cuda.h>

#include <cuda_runtime_api.h>



#include "projecto.cu"

#3
Posted 07/06/2009 02:39 PM   
Take a look at the deviceQuery project in the SDK and see what you're doing differently...

N.
Take a look at the deviceQuery project in the SDK and see what you're doing differently...



N.

#4
Posted 07/06/2009 02:45 PM   
Hi, i up this topic because i have the same problem,

how can i resolve it?
Hi, i up this topic because i have the same problem,



how can i resolve it?

#5
Posted 06/17/2010 01:19 PM   
try including builtin_types.h

That will get you all the types that the runtime library uses.
try including builtin_types.h



That will get you all the types that the runtime library uses.

#6
Posted 06/17/2010 01:30 PM   
I tried this without any result.

Buf i found one thing : i was compiling my C code with gcc and i got the undeclared error.

Now, compiling with g++ works (exactly same code, same includes and same flags). And the code can be run without problem.

gcc version used : gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
I tried this without any result.



Buf i found one thing : i was compiling my C code with gcc and i got the undeclared error.



Now, compiling with g++ works (exactly same code, same includes and same flags). And the code can be run without problem.



gcc version used : gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

#7
Posted 06/17/2010 02:05 PM   
[display problem, no need of a new message, sorry]
[display problem, no need of a new message, sorry]

#8
Posted 07/04/2010 02:51 PM   
[display problem, no need of a new message, sorry]
[display problem, no need of a new message, sorry]

#9
Posted 07/04/2010 02:51 PM   
Hey,

i got the same compiler error. In fact compiling the code with g++ solves this error. For everyone, who wants to use a c-only compiler .. after some time of searching for the declaration of cudaDeviceProp i found the following solution:

[code]
.
.
#ifdef __cplusplus
cudaDeviceProp deviceProp;
#else // !_cplusplus
struct cudaDeviceProp deviceProp;
#endif
.
.
[/code]

which solved the problem for me !

hope that helps, cheerz !
Hey,



i got the same compiler error. In fact compiling the code with g++ solves this error. For everyone, who wants to use a c-only compiler .. after some time of searching for the declaration of cudaDeviceProp i found the following solution:





.

.

#ifdef __cplusplus

cudaDeviceProp deviceProp;

#else // !_cplusplus

struct cudaDeviceProp deviceProp;

#endif

.

.




which solved the problem for me !



hope that helps, cheerz !

#10
Posted 05/09/2011 06:45 PM   
Scroll To Top

Add Reply